sumit
sumit

Reputation: 1

User Controls in asp.net

I have a user control on a web page . I want to use the values of the web page on my web user control.How can i do this

Upvotes: 0

Views: 94

Answers (2)

OrahSoft
OrahSoft

Reputation: 803

You can create and set property in your user control:

private string m_name = string.Empty;
public string UserName()
{
    return TextBox.Text;
}

Then in your ASP.NET page you can access this property by:

MyUserControl.UserName();

Upvotes: 1

Furqan Hameedi
Furqan Hameedi

Reputation: 4400

If you are talking of using page values in code i-e on server side , then you can access the page properties by casting the "this.Ownerpage" property of user control , and if you are talking of it on client side , then using Javascript/Jquery in combination with hidden fields you can do it easily.

Upvotes: 1

Related Questions