Hi I've created user control named test.ascs with one textbox. Now I added this user control in my default.aspx page. How can i access that textbox value from my default.aspx page?
is there any chance?
I usually expose the textbox's text property directly in test.ascx code behind like this:
public string Text
{
get { return txtBox1.Text; }
set { txtBox1.Text = value; }
}
Then you can get and set that textbox from the code behind of default.aspx like:
usrControl.Text = "something";
var text = usrControl.Text;
From your default page try to find the TextBox using your user control.
TextBox myTextBox = userControl.FindControl("YourTextBox") as TextBox;
string text = myTextBox.text;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With