User Controls in asp.net
I have a user control on a web p开发者_StackOverflowage . I want to use the values of the web page on my web user control.How can i do this
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.
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();
精彩评论