2009-12-01 67 views
1

我有一个c#asp.net 3.5应用程序 我想从某个事件后面的代码打开一个窗口。我有这个,但它不工作,并没有在萤火虫错误从代码后面调用JavaScript

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())); 
       } 
      } 
     } 

任何想法?

回答

1

当您查看源代码后,页面加载后,此代码是否实际呈现到源代码中? 您可以在this.Page.ClientScript...-line上设置断点,以验证实际上是否满足两个条件之前的条件?

4

假设前提条件为真。您需要将其他参数传递给RegisterClientStartupScript方法调用,以指示需要添加scriptTags。

Page.ClientScript.RegisterStartupScript(this.GetType(), "openCredentials", string.Format("radopen('Services.aspx?clientId={0}, Window_Services')", openCredentialsWindow_ClientId.ToString()),true); 
相关问题