Change parent page title from user control

I am new to asp.net. I have an asp.net page that uses a user control. In the Page_Load event of this control, I want to change the title of the parent aspx page. I need help on this.

+7
source share
3 answers

You can try to create a property in usercontrol and then call this property using your usercontrol instance on the page, for example

In UserControl

protected void Page_Load(object sender, EventArgs e) { this.MyProperty = "This is a test"; } public string MyProperty { get; set; } 

`On the 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; } 
+8
source share
 protected void Page_Load(object sender, EventArgs e) { Page.Title = "New Title"; } 
+10
source share

Set this to USERCONTROL:

 this.Page.Master.Page.Header.Title = "text text title title"; 
+2
source share

All Articles