Trigger an update of the UpdatePanel by a control that is in different ContentPlaceHolder

后端 未结 3 419
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 07:53

I have a page with two ContentPlaceHolders. One has a DropDown and another UpdatePanel with content.

How can I trigger update to the UpdatePanel by the DropDown\'s

相关标签:
3条回答
  • 2020-12-03 08:36

    In the code-behind file, you should be able to do:

    ScriptManager.RegisterAsyncPostBackControl(dropdown1);
    
    0 讨论(0)
  • 2020-12-03 08:40

    From http://msdn.microsoft.com/en-us/library/system.web.ui.asyncpostbacktrigger.aspx

    The control that the AsyncPostBackTrigger references must be in the same naming container as the update panel for which it is a trigger. Triggers that are based on controls in other naming containers are not supported.

    The workaround is to use the UniqueID of the control that the trigger is referencing. Unfortunately the UniqueID isn't qualified until the control has been added to its parent (and its parent has been added to its parent, all the way up the control tree).

    In your code behind, try:

    UpdatePanel1.Triggers.Add(new AsyncPostBackTrigger()
    {
        ControlID = DropDown1.UniqueID,
        EventName = "SelectedIndexChanged", // this may be optional
    });
    
    0 讨论(0)
  • 2020-12-03 08:50

    You can enforce update any of page UpdatePanels by call updatePanel1.Update() method on server side. For example during update updatePanel1 on button1.Click call updatePanel2.Update() and both panels will be updated.

    0 讨论(0)
提交回复
热议问题