我正在使用以下脚本仅在我的页面处于编辑模式时调用javascript函数:
protected void Page_PreRender(object sender, EventArgs e)
{
if (EditMode)
ClientScript.RegisterStartupScript("".GetType(),
"EnableSelectableKey",
"EnableSelectableForRolesLists();",
true);
}
添加更新面板后,脚本尚未调用。
如何解决问题?
答案 0 :(得分:4)
使用Sys.WebForms.PageRequestManager.endRequest
作为Dave_Stott说是一种更简洁的方法(如果在谈论UpdatePanels
和客户端/服务器交互时存在“干净”这样的事情)。但您也可以简单地将代码更改为使用ScriptManager
而不是ClientScript
,它应该可以正常运行:
ScriptManager.RegisterStartupScript("".GetType(),
"EnableSelectableKey",
"EnableSelectableForRolesLists();",
true);
答案 1 :(得分:1)
查看:http://msdn.microsoft.com/en-us/library/bb383810.aspx
这应该指向正确的方向:)