Ajax Update Master Page From Content Page

In this blog post we are going to see how can we update the master page from content page using ajax updatepanel in ASP.NET. The sample website we are going to build will have a content page which allows to change the header of the website(which is present in master page) via Ajax.

The tasks involved in creating this website are as follows:

  • Create an updatepanel in masterpage which holds the website header.
  • Create a method in MasterPage codebehind which changes the website header.
  • Create the content page with master page reference and an update panel which holds controls to triggers the header change.
  • Call the MasterPage method from content page.

1. Create an updatepanel in masterpage which holds the website header.

Make Sure the two properties of UpdatePanel “ChildrenAsTriggers” is set to false and “UpdateMode” is set to conditional, to prevent the unneccessary updation of updatepanel from its child controls.

2. Create a method in MasterPage codebehind which changes the website header.

3. Create the content page with master page reference and an update panel which holds controls to triggers the header change.

4. Call the MasterPage method from content page.

Summary:

In this blog we have seen how can we update the master page from the content page using ajax update panel. You can download the source code from here

Comments