How to change the imageurl of the image control that exists in a usercontrol

In the .ascx: <asp:Image id='Image1' runat='server'></asp:Image> In .aspx VB.NET <uc1:UCImage id='UCImage1' source='b2346.jpg' runat='server'></uc1:UCImage> Dim UC As UserControl Dim imgUC As System.Web.UI.WebControls.Image UC = Page.FindControl('UCImage1') imgUC = UC.FindControl('Image1') imgUC.ImageUrl = 'b2346.jpg' C# UserControl UC ; System.Web.UI.WebControls.Image imgUC ; UC = (UserControl)Page.FindControl('UCImage1'); imgUC =(System.Web.UI.WebControls.Image)UC.FindControl('Image1'); imgUC.ImageUrl = 'b2346.jpg';

How to add user control dynamically into another usercontrol

Here is an example of adding one UserControl into another: uc1.ascx: <asp:Label runat='server' text='uc1' ID='Label1' /> <asp:Panel runat='server' id='p1' >Panel UC1</asp:Panel> uc2.ascx: <br><asp:Label runat='server' text='uc2' ID='Label1' /> VB.NET Dim uc1 As UserControl = CType(LoadControl('uc1.ascx'), UserControl) Controls.Add(uc1) Dim uc2 As Control = uc1.LoadControl('uc2.ascx') Dim p1 As Control = uc1.FindControl('p1') p1.Controls.Add(uc2) C# UserControl uc1 = (UserControl)LoadControl('uc1.ascx'); Controls.Add(uc1); Control uc2 = uc1.LoadControl('uc2.ascx'); Control p1 = uc1.FindControl('p1'); p1.Controls.Add(uc2);

How to pass a parameter to a user control?

Create a User Control Below Code goes in User Control <asp:ImageButton id='ImageButton1' runat='server'></asp:ImageButton> Create a property called source VB.NET Public Property source() As String Get Return ImageButton1.ImageUrl End Get Set(ByVal Value As String) ImageButton1.ImageUrl = Value End Set End Property C# public string source { get { return ImageButton1.ImageUrl; } set { ImageButton1.ImageUrl = value; } } Now in your webform: Drag and drop User Control and set the source property. <uc1:UCImageButton source='b2346.jpg' id='UCImageButton1' runat='server'></uc1:UCImageButton>