简体   繁体   English

内容页面呈现后在母版页面上触发哪个事件

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

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. 我有一个要求,只有在内容页面设置了页面标题之后,才需要将页面标题的值传递给Facebook共享插件。 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). 有几个页面(动态数据页面)在特定控件的PreRender事件上设置了页面标题(我无法更改此设置)。

If I pass the content page title on Master page's PreRender it returns the unset value as Master page's PreRender is fired before content page's control PreRender . 如果我在母版页的PreRender上传递内容页标题,则它将返回未设置的值,因为在内容页的控件PreRender之前会PreRender母版页的PreRender I tried passing the value in the master page's Unload event but it did not work! 我尝试在母版页的Unload事件中传递值,但是它不起作用! 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 参考: ASP.NET母版页和内容页中的事件

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);
}

使用页面卸载事件执行最终清理,如关闭文件,释放内存等...如果在此处设置页面标题,将不会呈现....您必须在控件预渲染事件本身上设置标题...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM