Need to call server side event using __doPostBack

2019-05-02 00:09发布

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条回答
萌系小妹纸
2楼-- · 2019-05-02 01:07

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>
查看更多
登录 后发表回答