Which event is fired on master page after content pages have rendered

320 views Asked by At

I have a requirement where I need to pass the value of page title to Facebook share plugin only after the page title has been set by the content page. There are a few pages(Dynamic Data pages) where the page's title is set upon a specific control's PreRender event (I cannot change this).

If I pass the content page title on Master page's PreRenderit returns the unset value as Master page's PreRender is fired before content page's control PreRender. I tried passing the value in the master page's Unload event but it did not work! How do I achieve this?

So the question can be summarised as, perform something on master page after the content pages have performed all of their tasks and are ready to unload.

Is there a way to do this in master page itself or will I have to do this in the individual pages?

Reference: Events in ASP.NET Master and Content Pages

Dynamic Data Page:

string Location = null;
protected void DynamicFilter_PreRender(object sender, EventArgs e)
{
    DynamicFilter Filter = (DynamicFilter)sender;    
    MetaColumn metaColumn = table.GetColumn(Filter.DataField);    
    QueryableFilterUserControl fuc1 = Filter.FilterTemplate as ForeignKeyFilter;

    if (fuc1 != null && fuc1.FilterControl != null)
    {
        DropDownList ddl = fuc1.FindControl("DropDownList1") as DropDownList;                
        if (ddl != null)
        {
            if (metaColumn.DisplayName == "Location")
            {
                if (ddl.SelectedIndex != 0)
                {
                    Location = ddl.SelectedItem.Text;
                }
            }
        }
    }

    if (Location != null)
    {
         // set the page title based on the location             
         Page.Title = String.Format("Recent {0} Fares", Location);
    }
}

This function sets the content page's(a dynamic data page) title. Now I need to access this title on the my master page only after it has been set.

Master Page:

protected void Page_Load(object sender, EventArgs e)
{
    // pass the value of page title to SocialNetworkingHelper class to do some work
    SocialNetworkingHelper.SetSocialMediaMetaTag(this.Page, this.Page.Title);
}
1

There are 1 answers

0
Anand Jillawar On

use page unload event to perform final cleanup like closing files, releasing memory etc...if you set page title here it will not be rendered....you have to set title on control prerender event itself...