Live Chat Icon For mobile
Live Chat Icon

How to pass a parameter to a user control?

Platform: ASP.NET| Category: User Controls

Create a User Control
Below Code goes in User Control

<asp:ImageButton id='ImageButton1' runat='server'></asp:ImageButton>

Create a property called source

Public Property source() As String
		Return ImageButton1.ImageUrl
	End Get
	Set(ByVal Value As String)
		ImageButton1.ImageUrl = Value
	End Set
End Property


public string source 
		return ImageButton1.ImageUrl;
		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>

Share with

Related FAQs

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

Please submit your question and answer.