Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update label on MasterPage from content page with UpdatePanel without full Postback

Does there exist a solution for this scenario?

I have a content page which contains an UpdatePanel and has a combobox. When the combobox value is changed I want to change a label in my Master page. So, the main problem for me is that I don't want to make a full postback with every combobox value changing. Is there some trick to overcome full postback?

Thanks in advance.

like image 797
apros Avatar asked Feb 25 '23 05:02

apros


1 Answers

  • Put your label in your MasterPage in a separate UpdatePanel.
  • On dropdownlist's SelectedIndexChange make an asnychronous postback
  • From the SelectedIndexChanged-Handler call a function on Masterpage(f.e. ShowMessage) that changes the Text of the Label and calls Update on the Masterpage's UpdatePanel.

You can access your MasterPage's functions in the following way(from ContentPage just as UserControls in ContentPage):

((MyMaster)this.Page.Master).ShowMessage(text);

in VB.Net

DirectCast(Me.Page.Master, MyMaster).ShowMessage(text)

Of course you have to replace MyMaster with the actual type of your MasterPage and implement a public function(sub) that changes the Label's Text(ShowMessage in this example) and updates the UpdatePanel in the MasterPage. Set its UpdateMode property to Conditional and make sure that the ChildrenAsTriggers property is false and that no explicit triggers are defined for the panel.

like image 101
Tim Schmelter Avatar answered Apr 07 '23 19:04

Tim Schmelter