问题
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