views:

113

answers:

2

Hi all,

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

+3  A: 

Hai have a look at this http://www.codedigest.com/CodeDigest/22-Passing-value-from-Page-to-UserControl-in-ASP-Net.aspx

Pandiya Chendur
Hai melt have you got answer
Pandiya Chendur
Perfect, thanks a lot.
Melt
+4  A: 

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.

ARS
+1. Beat me by 5 sec.
RickNZ
+1 for highlighting the tight coupling issue.
Ralph Willgoss
..and how would I do that guys?
Melt
create a public property on the control and refer to in your page code e.g. myControl.myProperty = "hello";
adrianos