c# - Page.Title set in child's Page_Init empty in parent's Page_PreRender -


there 2 files involved:

  • childpage.aspx.cs class childpage : parentpage
  • parentpage.cs class parentpage : system.web.ui.page

childpage.aspx.cs has method

protected page_init(object sender, eventargs e)  {     page.title = "abc"; } 

parentpage.cs has property , method

public string mymodifiedtitle  {         {         // adding 123 super important.         return page.title + "123";     } }  protected override void onprerender(eventargs e) {     base.onprerender(e);      // add open graph meta tag modified title.     htmlmeta tag = new htmlmeta();     tag.attributes.add("property", "og:title");     tag.content = mymodifiedtitle;     header.controls.add(tag); } 

page.title set "abc", og:title meta tag set "123" instead of "abc123".

why page.title cleared out before onprerender?


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -