Reputation: 501
I have a textbox on my aspx page and I need a usercontrol to be able to see or access that value, how would I do that please.
I created a public property on my aspx page
public string txtBoolValue
{
get { return this.txtBool.Text;}
}
How do I call that from my ascx page?
Thanks
Melt
Upvotes: 3
Views: 18657
Reputation: 19
Try this:
((Textbox)this.Parent.FindControl("YOUR TEXTBOX NAME IN ASPX PAGE")).Text
Upvotes: 2
Reputation: 4225
Instead of creating a property on page why don't you create a property on user control which can be set by the page. The code you mentioned in your question will create tight coupling between the page and user control.
Upvotes: 15
Reputation: 35268
Hai have a look at this http://www.codedigest.com/CodeDigest/22-Passing-value-from-Page-to-UserControl-in-ASP-Net.aspx
Upvotes: 5