Need to call server side event using __doPostBack

*爱你&永不变心* 提交于 2020-01-13 10:33:27

问题


I have server side event like this.

protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
    {
         // implementation here.
    }

I am trying to call it from client side javascript. I have tried __doPostBack("contextMenuItemID", "some string")

it posts the page back to server, but this does not invoke the original ContextMenuItemClick event. How can I invoke the original contextMenuItemClick event with proper event Args?


回答1:


You'll want to look at using the ClientScriptManager.GetPostBackEventReference method. This will create the correct javascript call ("__doPostBack") for the control/action using the ClientScriptManager (untested example):

<script type="text/javascript">
    function callPostBack() {
        <%= Page.ClientScript.GetPostBackEventReference(RadTreeView1, String.Empty) %>;
    }
</script>


来源:https://stackoverflow.com/questions/10483271/need-to-call-server-side-event-using-dopostback

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