Reputation: 43
I will like to know how I can access the textbox controls that I have in my WebUserControl from my Parent aspx page. I want that the user enters the data in texbox at the WebUserControl, then press the "Save" button which is in the parent page and the will be saved at SQL Server.
Upvotes: 4
Views: 9394
Reputation: 62260
You can expose the Text of TextBox of WebUserControl as public.
public partial class WebUserControl : System.Web.UI.UserControl
{
public string MyText
{
get { return MyTextBox.Text; }
set { MyTextBox.Text = value; }
}
}
public partial class WebForm1 : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
string value = WebUserControl1.MyText;
}
}
Upvotes: 6