服务器端的Javascript [英] Javascript in server side

查看:99
本文介绍了服务器端的Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string script = "<script language="\"javascript\"" type="\"text/javascript\"">";
            script += "function chartPopup2()";
            script += "{";
            script += "alert(‘test’);";
            script += "}";
            script += "</script>";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "test", script);---this line is not working


上面用btn click事件编写的代码在服务器端.

我单击了按钮,但JavaScript无法正常运行.
请给我必要的答案.


Above code written in btn click event in server side.

I clicked button but JavaScript is not working.
Please send me needful answer.

推荐答案

这是
This is the THIRD [^]time you are asking the same thing.
Are you that dumb? A simple thing has been suggested to you.

How did you bind this script with your button?
Did you do:
btnClick.Attributes.Add("onclick", "chartPopup2();");


您需要将JavaScript方法绑定到按钮.系统不够智能,无法单独将您的JavaScript方法应用于按钮.

如果您无法确定,请先学习一些书籍,然后再学习如何学习.


You need to bind the JavaScript method to the button. System is not intelligent enough to apply your JavaScript method to a button by itself.

If you are unable to make out, go study some books, learn how to learn first.


此代码看起来很可怕.您也可以使用按钮的OnClientClick来调用javascript.为什么要这样做?无论如何,在此代码中,您都在声明一个函数,但没有调用它.删除该功能,仅保留该警报,然后它将起作用.或者您可以做类似的事情,
This code is looking horrible. You can also use OnClientClick of button for calling javascript. Why you want to do like this? Anyway in this code you are declaring a function, but not calling it. Remove that function and keep only that alert, then it''ll work. Or simply you can do something like,
<br />
Page.ClientScript.RegisterStartupScript(this.GetType(), "test", "alert(''test'');", true);


这篇关于服务器端的Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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