ASP.NET代码页中的Javascript代码 [英] Javascript code in asp.net code page

查看:64
本文介绍了ASP.NET代码页中的Javascript代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试在asp.net服务器端的页面加载中编写JavaScript确认脚本.
有人有样品吗?

谢谢


sini_tg

Hi,

I am trying to write a javascript confirmation script in the page load of a asp.net server side.
anyone got any samples?

Thanks


sini_tg

推荐答案

  public void Page_Load(Object sender, EventArgs e)
  {
    // Define the name and type of the client scripts on the page.
    String csname1 = "ConfirmationScript";
    Type cstype = this.GetType();

    // Get a ClientScriptManager reference from the Page class.
    ClientScriptManager cs = Page.ClientScript;

    // Check to see if the startup script is already registered.
    if (!cs.IsStartupScriptRegistered(cstype, csname1))
    {
      String cstext1 = "alert('Confirmed!');";
      cs.RegisterStartupScript(cstype, csname1, cstext1, true);
    }
  }


这篇关于ASP.NET代码页中的Javascript代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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