We can add a Web User Control Dynamically (At Runtime) in 2 steps.
Step 1 : Add a "PlaceHolder" in your aspx page.
Step 2 : Write the following code on page load (Code Behind).
Code :
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim UCDynamic As Control
'WebUserControl.ascx : User Control path
UCDynamic = LoadControl("WebUserControl.ascx")
PlaceHolder1.Controls.Add(UCDynamic)
End Sub
No comments:
Post a Comment