how to trigger updatepanel within a javascript function

后端 未结 2 1312
梦如初夏
梦如初夏 2021-02-05 18:24

i have an updatepanel in my asp.net web page. I want to trigger the updatepanel within a javascript function insead of triggering with a button.
In order to do that, i used

2条回答
  •  情话喂你
    2021-02-05 18:40

    Just create a javascript function and execute the generated postback event:

    <%=ClientScript.GetPostBackEventReference(myUpdatePanel, "")%>
    

    The above statement is put on your aspx page, and it references the exact same code generated from the server to cause a postback for your panel. You can use it by putting it inside a function on the client side:

    function fncUpdatePanel () {
        <%=ClientScript.GetPostBackEventReference(myUpdatePanel, "")%>;
    }
    

    Then you can attach that function to any event on your page (even a mouseover event). This example uses a server side to attach the event:

    myUpdatePanel.attributes('onmouseover', 'fncUpdatePanel()')
    

提交回复
热议问题