简体   繁体   中英

Change Master Page Content without loading page multiple times

I have Master and Content Page.The Layout is like Header and Footer are in Master page and rest contents are in content/child page.

Now I want to change the header and footer of master page dynamically.To do this,I have coded Page_load event of master page.

But Actual problem comes that when Master page's header and footer changes,the page loads multiple times..

Is there any way to solve this problem.. I want to change header and footer of master page for specific time without refreshing content page.

I have seen many post, but i did not find any accurate answer..

My code is : this is the page_load event of master page ..

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DIVHeader.InnerHtml = obj.getHeaderHTMLFinal();
            DIVFooter.InnerHtml = obj.getFooterHTMLFinal();
        }
    }

Where do you want to change the footer on the Master Page?

You could wrap the header and footer in ContentPlaceholder controls and adjust them in client pages directly.

You can also interact with the Master Page in client pages in code behind via the Page.Master property.

Try to use an updatepanel. You can update the content of the panel without reload the whole page.

If in your header or footer you do not have controls that triggers an update then you can manual trigger the update of the panel from code behind using conditional update.

hope that helped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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