怎样才能在asp.net中调用前台页面中写的一个脚本啊 ,你们看一下哪里写错了
Response.Write("<script>show()</script>");
其中show为页面中的一个JS方法 谢谢各位了!

解决方案 »

  1.   

    Page.ClientScript.RegisterStartupScript(this.GetType(), "key", "js();", true):
      

  2.   

     ScriptManager.RegisterStartupScript(this, this.GetType(), "showInfo", "show();", true);
      

  3.   

    ClientScript.RegisterStartupScript是在html文档末尾生成
    <script type="text/javascript">
    show();
    </script>
    这样的东西。你说它能不执行show()方法吗?
      

  4.   

     Radio1.Attributes.Add("onclick", "JavaScript:changeDiv();");
      

  5.   


    这样是你在后台注册了一个JS方法 在页面中调用该方法 那他肯定执行啊  
    你这种效果跟我的相反啊 我的是在UI 中写了一个JS方法想要在后台中调用该方法啊
    以前用Response.Write("<script>show();</script>")就可以不知道为什么现在却报有脚本错误
      

  6.   

    Page.ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>show();</script>", true);
      

  7.   

    在页面底部放一个Literal或Label控件然后把你的Response代码改成Literal1.Text = "<script>show();</script>"即可
    原因是Response.Write将写在页面顶部,但这个时候你的自定义的show方法还没有被页面加载,因此无法呈现出效果.所以需要在页面底部来执行你的自定义方法
      

  8.   

      Page.ClientScript.RegisterStartupScript(this.GetType(), "key", "JavaScript:yanzheng();;", true);晕那这样可以八?
      

  9.   


    报错 就对了 这样输出的脚本 在页面的最前端, 浏览器找不到你写的 show() 方法