在母版更新标签从UpdatePanel的内容页面,而不完全回发 [英] Update label on MasterPage from content page with UpdatePanel without full Postback

查看:191
本文介绍了在母版更新标签从UpdatePanel的内容页面,而不完全回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在这种情况的解决方案?

Does there exist a solution for this scenario?

我有一个包含一个UpdatePanel并具有组合框内容页。当组合框的值被改变我想在我的母版页来更改标签。所以,对我来说,主要问题是,我不想做一个完整的回传与每一个组合框的值变化。有一些技巧,克服完全回发?

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?

先谢谢了。

推荐答案


  • 把你的标签在你的母版在一个单独的UpdatePanel。

  • 在DropDownList的SelectedIndexChange做出asnychronous回发

  • 从的SelectedIndexChanged处理程序调用上的母版功能(f.e。 ShowMessage ),它改变了标签的文本和母版的UpdatePanel中调用Update。

  • 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.
  • 您可以访问你的母版的以下列方式功能(从ContentPage就像在ContentPage用户控件):

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

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

    在VB.Net

    in VB.Net

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

    当然,你必须与实际类型的母版来代替 MyMaster 和实施公共功能(子)改变标签的文本( ShowMessage 在这个例子中)和更新的母版在UpdatePanel。其UpdateMode属性设置为条件,并确保该ChildrenAsTriggers属性为false,并且没有明确的触发器为面板定义。

    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.

    这篇关于在母版更新标签从UpdatePanel的内容页面,而不完全回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆