更新时间:2023-12-05 22:59:04
我的头顶:
GetType()
而不是 typeof(Page)
以便将脚本绑定到您的实际页面类而不是基类,Page.UniqueID
,这没有那么有意义,因为它应该被命名控件使用,PreRender
阶段注册脚本:GetType()
instead of typeof(Page)
in order to bind the script to your actual page class instead of the base class,Page.UniqueID
, which is not that meaningful since it's supposed to be used by named controls,PreRender
phase:protected void Page_PreRender(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, GetType(), "YourUniqueScriptKey",
"alert('This pops up');", true);
}