我有一个 c# asp.net 3.5 应用程序 我试图在某个事件后从代码后面打开一个窗口。我有这个,但它不工作, Firebug 中没有错误
protected override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
if (openCredentialsWindow) {
if (openCredentialsWindow_ClientId != Guid.Empty) {
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "openCredentials", string.Format("radopen('Services.aspx?clientId={0}, Window_Services')", openCredentialsWindow_ClientId.ToString()));
}
}
}
有什么想法吗?
最佳答案
假设先决条件为真。您需要向 RegisterClientStartupScript
方法调用传递一个附加参数,以指示需要添加 scriptTags。
Page.ClientScript.RegisterStartupScript(this.GetType(), "openCredentials", string.Format("radopen('Services.aspx?clientId={0}, Window_Services')", openCredentialsWindow_ClientId.ToString()),true);
关于javascript - 从后面的代码调用 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1828566/