Live Chat Icon For mobile
Live Chat Icon

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

Platform: ASP.NET| Category: User Controls

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';

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.