vb.net - Nesting ASP.NET user controls programmatically -


I have a user control that programmatically covers another user control multiple times, but the end result is That does not generate any HTML control over all.

Default.aspx

  & lt;% @ Page language = "vb" AutoEventWireup = "false" CodeBehind = "Default.aspx.vb" Inheritance = "Test Application Default "%" & Lt;% @ tagname = "ten" tagfix = "m" SRC = "~ / ten .ascx"%> & Lt; Html & gt; & Lt; Head runat = "server" & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form id = "form1" runat = "server" & gt; & Lt; Me: ten id = "thisTen" runat = "server" /> & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

Ten.ascx

  & lt;% @ control language = "vb" AutoEventWireup = "false" CodeBehind = "Ten.ascx.vb" Inherit = "Test App.Ten"% & gt; & Lt; ASP: panel id = "list" run = "server" & gt; & Lt; / Asp: panel & gt;   

Ten.ascx.vb

  Public Class Ten Inheritance System. Web. UI. User control protected sub page_ent () for me as an integer for me = 0 to 11 list Control. The next end sub end class   

one.Sax

  & lt;% @ control language = "vb" (the new one (I.ToString) AutoEventWireup = "false" codebahind = "a.csax.wb" inheritance = "test application."%> & Lt; Asp: Button ID = "OneButton" text = "Press me!" Runat = "server" />   

One.ascx.vb

  acquire a public class system. Web.UI.UserControl private _number string sub as new (Byval number as string) _number = number ending sub-protected sub OneButton_Click (as object, in the form of sender, byval, as by event) OneButton the handle. String = "& lt; script type =" "text / javascript" "& gt; +" alert ('button "+ _number +"'); "+" & lt; / Script> "ScriptManager.RegisterStartupScript (Me, Me.GetType ()," ServerControlScript ", script, True) End Sub End Class   

Edit:

Use of load control (ten.spx)

  dim p () string = {I.ToString} as slow o one = m load control ( New one (""). GetType, p list. Add control (o)   

Edit 2:

  As a slow o one = Me.LoadControl ("~ / One.ascx") o._number = I.ToString List.Controls.Add (o)    

< Div class = "post-text" itemprop = "text">

I have this operation in the OnInit event It may, but it may be related to your problem or, instead, I can load the control in the download event.

However, the use of the new keyword Sorry, but I only know C # and do not know the exact translation:

in C #:

  One A = (a) this.LoadControl ("~ / controls /One.ascx");   

Does this look correct in VB.NET?

  A similar one = Me.LoadControl ("~ / Controls / One.ascx")   

You have to remove the constructor and load the control After just have to set the property.

Comments