Page losing title after UpdatePanel asyncpostback

前端 未结 6 1303
时光取名叫无心
时光取名叫无心 2021-02-13 02:45

I have just noticed recently that my page title will reset to the standard \"Untitled Page\" after I perform an asyncpostback from inside my UpdatePanel in the main

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-13 03:40

    You could put the Page title in Viewstate and then just grab the string in the button postback Click event and assign it to Page.Title

        public string MyPageTitle
        {
            get
            {
                return (string)ViewState["MyPageTitle"];
            }
            set
            {
                ViewState["MyPageTitle"] = value;
            }
        }
    

    On Page load assign: MyPageTitle = "My Cool Web Page Title"; Then in button click event:

    protected void MyLinkButton_Click(object sender, EventArgs e)
        {
    
           Page.Title = MyPageTitle;
    
        }
    

提交回复
热议问题