Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在asp页面中运行javascript_Javascript_Asp.net - Fatal编程技术网

在asp页面中运行javascript

在asp页面中运行javascript,javascript,asp.net,Javascript,Asp.net,我希望能够在asp页面中运行一些基本的javascript客户端,因此作为测试,我有以下内容: <head> <script type="text/javascript"> function TestClick() { alert("here");} </script> </head> <body> <form id="form1" runat="server"> <butt

我希望能够在asp页面中运行一些基本的javascript客户端,因此作为测试,我有以下内容:

<head>
   <script type="text/javascript">
      function TestClick() { alert("here");}
   </script>
</head>

<body>
   <form id="form1" runat="server">
      <button onclick="TestClick()">Click Me</button>
   </form>
</body>

函数TestClick(){alert(“here”);}
点击我
但当我运行此命令时,我得到了错误:

0x800a1391-JavaScript运行时错误:“TestClick”未定义


我一定是在做傻事……

可能与
runat=“server”
有关,因为服务器没有这个功能。JS-wise,它正在工作,因此这是一个asp问题。如果我从
form1
中删除
runat=“server”
,那么页面错误就会出现。我想你可以删除runat服务器并手动将for发布到服务器。TestClick函数将要做什么?它将要做一个window.postMessage,我认为我在asp代码中做不到这一点。好吧,它在正常的aspx页面中正常工作。您确定错误不是在其他地方生成的吗?