从code后面的JavaScript调用 [英] Calling javascript from code behind

查看:147
本文介绍了从code后面的JavaScript调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#asp.net 3.5应用程序
我试图打开从code窗口的特定事件后落后。我有这个,但它不工作,有萤火中没有错误

I have a c# asp.net 3.5 app I am trying to open a window from code behind after a certain event. I have this but its not working and there are no errors in 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()));
                }
            }
        }

任何想法?

推荐答案

假设pre-条件为真。你需要一个额外的参数传递给 RegisterClientStartupScript 方法调用,以表明scriptTags需要添加。

Assuming that the pre-conditions are true. You need to pass an additional parameter to the RegisterClientStartupScript method call to indicate that scriptTags need to be added.

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

这篇关于从code后面的JavaScript调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆