2012-05-07 34 views
5

我有這樣的服務器端事件。需要使用__doPostBack調用服務器端事件

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

我想從客戶端JavaScript調用它。我試過__doPostBack(「contextMenuItemID」,「一些字符串」)

它將頁面發回服務器,但是這不會調用原始的ContextMenuItemClick事件。我如何使用適當的事件參數調用原始contextMenuItemClick事件?

回答

7

你會想看看使用ClientScriptManager.GetPostBackEventReference方法。這將爲使用ClientScriptManager控制/動作正確的JavaScript調用( 「__doPostBack」)(未經測試的例子):

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