In the examples, you need to use the animation creation control.WinformIs easy to implement,WebI spent half a day learning and now I want to record it here: Based onASP. net2.0You need to remember how the preceding controls can be used to manually create a step, and how to use these methods.
To make the controls generated by the notebook orderly, drag oneTablePut it on the plane. Then place the control inTableOfCell. I am in this sort of suborder. I wonder if you have a better solution. Please try again later.
Add a widget to the notebook.Page_initAdd a token to the event.
OK, Let's talk a little bit about it.:
Create a method named:CreatecontroldynamicallyOf, using the following token:
Createdynamic
Sub Createcontroldynamically ( Byval Ncount As Integer )
For I As Integer = 1 To Ncount
Dim Tr As Tablerow = New Tablerow ()
Dim TC As Tablecell = New Tablecell ()
Dim Mylabel As Label = New Label ()
' This parameter sets the ID of the label. For different labels, you must set different IDs.
Mylabel. ID = " LBL " & I
Mylabel. Text = " Critial " & I
TC. Controls. Add (mylabel)
Tr. cells. Add (TC)
Dim TC2 As Tablecell = New Tablecell ()
Dim Mytextbox As Textbox = New Textbox ()
Mytextbox. ID = " Txt " & I
Mytextbox. Text = " Textbox " & I
Tc2.controls. Add (mytextbox)
Tr. cells. Add (TC2)
Me. TBL. Rows. Add (TR)
Next
When usedPage_init, Directly knockCreatecontrodynamically (5)JustOK. ThenAspxThe source region:
Aspx
<% @ Page Language = " VB " Autoeventwireup = " False " Codefile = " Default. aspx. VB " Inherits = " _ Default " %>
<!Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head Runat = "Server" >
< Title > Create control dynamically </ Title >
</ Head >
< Body >
< Form ID = "Form1" Runat = "Server" >
< Div >
< ASP: Table ID = "TBL" Runat = "Server" >
< ASP: tablerow ID = "Trlbl" Runat = "Server" >
</ ASP: tablerow >
< ASP: tablerow ID = "Trtbx" Runat = "Server" >
</ ASP: tablerow >
</ ASP: Table >
< BR />
< ASP: button ID = "Btnok" Runat = "Server" Text = "Button" /> </ Div >
</ Form >
</ Body >
</ Html >
OK,F5What did you see when it was running,5Line2The 10 controls of the column are displayed.
So how can I use your dynamic volume creation control? To use these controls, you must first knowIDFor the control operators mentioned above, I added1,2,3,4,5Such. This sub-name is also recommended when you are using it for later programming. The following code is used in the next generation:
Ctype ( Me . Findcontrol ( " TBX1 " ), Textbox). Text = "Custom text value"
Http://www.cnblogs.com/jinliangliu/archive/2007/10/20/931600.html