UpdatePanel Triggers, how to set trigger event for __doPostBack?

梦想与她 提交于 2019-12-12 03:06:23

问题


I have an UpdatePanel on my page which I would like to set up some triggers for:

<asp:updatepanel id="updatepanel1" runat="server">
     <contenttemplate>
          <asp:label id="lblfoo" runat="server />
     </contenttemplate>
     <triggers>
          <asp:asyncpostbacktrigger controlid="CormantRadTabStrip1" eventname="???" />
     </triggers>
</asp:updatepanel>

and I have some related javascript:

function CloseAndSave() {
    window.__doPostBack(CormantRadTabStrip1);
}

On the server-side I have made bar implement the IPostBackEventHandler interface.

There doesn't seem to be an explicit event name for this sort of thing, though? What should I sent the eventname to be?

Thanks

public class CormantRadTabStrip : RadTabStrip, IPostBackEventHandler
{
    /// <summary>
    /// This is called when the GlobalSettings dialog window closes.
    /// </summary>
    /// <param name="eventArgument">JSON passed to the event representing state of tabs</param>
    void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
    {
        UpdateTabs();
    }
}

回答1:


The eventname should be whatever type of event your bar (or CormantRadTabStrip1) control causes the postback. See the msdn doc for some common (default) eventname values.




回答2:


You can add hidden Button and specify OnClientClick event handler to window.__doPostBack(CormantRadTabStrip1);

Then modify AsyncPostBackTrigger with following

<triggers>
    <asp:asyncpostbacktrigger controlid="YouButtonID" eventname="ClientClick" />
</triggers>


来源:https://stackoverflow.com/questions/8084691/updatepanel-triggers-how-to-set-trigger-event-for-dopostback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!