开发者

User Controls in asp.net

开发者 https://www.devze.com 2023-02-15 18:18 出处:网络
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 thisIf you are talking of using page values in code i-e on server

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消