Update label on MasterPage page from UpdatePanel page without full postback

Is there a solution for this scenario?

I have a content page containing an UpdatePanel and having dropdowns. When the combobox value changes, I want to change the label on my main page. So, the main problem for me is that I do not want to do a full postback when the combobox value changes. Is there any trick to overcome the complete reverse gear?

Thanks in advance.

+4
source share
1 answer
  • Put your label on your MasterPage in a separate UpdatePanel.
  • In the SelectedIndexChange drop-down list, perform asynchronous postback
  • In the SelectedIndexChanged handler, a function is called on the main page (fe ShowMessage ), which changes the label text and causes an update on the update page of the master page.

You can access your MasterPage functions as follows (from ContentPage, like UserControls in ContentPage):

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

at VB.Net

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

Of course, you must replace MyMaster with the actual type of your MasterPage and implement a public function (sub) that changes the label text ( ShowMessage in this example) and updates the UpdatePanel in MasterPage. Set the UpdateMode property to Conditional and verify that the ChildrenAsTriggers property is false and that explicit triggers are not defined for the panel.

+8
source

Source: https://habr.com/ru/post/1338287/


All Articles