Im a VB.NET beginnger, can anyone tell me how I can dynamically add a div table row or how I can loop a section of html? thanks.
-
ASP.Net, or some kind of screen scraping? And if asp.net, what point in the page lifecycle are we talking about? Some more context would really be appreciated.Joel Coehoorn– Joel Coehoorn2009-05-29 13:57:58 +00:00Commented May 29, 2009 at 13:57
-
At Page Load. I want to create a row of input boxes for each additional customer. I then want to fix an id at the end of each input box ie CustomerFullName1,CustomerDOB1,CustomerFullName2,CustomerDOB2, etc.Mark– Mark2009-05-29 14:02:59 +00:00Commented May 29, 2009 at 14:02
-
I pass the number of additional customers at the page creation.Mark– Mark2009-05-29 14:03:37 +00:00Commented May 29, 2009 at 14:03
Add a comment
|
1 Answer
I'm making a few assumptions about what your doing (such as you're using ASP.Net) but you can use the Repeater control to loop a section of HTML.
<asp:Repeater ID="myRepeater" runat="server">
<ItemTemplate>
<div>What you want to loop here</div>
</ItemTemplate>
</asp:Repeater>
But of course you'll have to databind the repeater for it to loop through the items that it's databound to. You could also do an inline loop:
<% for (int i = 0; i < 5; i++)
{ %>
<div>Something repeated here</div>
<% } %>
You'll have to put the for loop into VB syntax of course.
2 Comments
Max Schmeling
Just put a property in the code behind of the page and then you can access that property like normal from the inline loop (this.MyProperty)