需要使用__doPostBack调用服务器端事件 [英] Need to call server side event using __doPostBack
问题描述
我有这样的服务器端事件.
I have server side event like this.
protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
{
// implementation here.
}
我正在尝试从客户端javascript调用它.我已经尝试过__doPostBack("contextMenuItemID",某些字符串")
I am trying to call it from client side javascript. I have tried __doPostBack("contextMenuItemID", "some string")
它将页面重新发布到服务器,但这不会调用原始的ContextMenuItemClick事件.如何使用适当的事件Args调用原始的contextMenuItemClick事件?
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?
推荐答案
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>
这篇关于需要使用__doPostBack调用服务器端事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!