I am a newbie to asp.net. I have an asp.net page which uses a user control. On Page_Load event of this control, I want to change the title of the parent aspx page. I need help on this please.
protected void Page_Load(object sender, EventArgs e)
{
Page.Title = "New Title";
}
You can try create a property in usercontrol and next call this property using your instance of usercontrol in page like
In UserControl
protected void Page_Load(object sender, EventArgs e)
{
this.MyProperty = "This is a test";
}
public string MyProperty { get; set; }
` In Page
protected void Page_Load(object sender, EventArgs e)
{
WebUserControl11.PreRender += new EventHandler(WebUserControl11_PreRender);
}
void WebUserControl11_PreRender(object sender, EventArgs e)
{
string str = WebUserControl11.MyProperty;
this.Header.Title = str;
}
Set this in your USERCONTROL:
this.Page.Master.Page.Header.Title = "text text title title";
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