作者pyrochlore (患得患失)
看板Ajax
标题Re: [问题] javascript 与 ASP.NET
时间Tue Oct 21 03:22:59 2008
※ 引述《CoMix (CoMix)》之铭言:
: 我想问的问题 不太会表达 我用简单的程式码来说我要的问题好了 ^^"
: <script runat="server">
: </script>
: <html xmlns="http://www.w3.org/1999/xhtml" >
: <head runat="server">
: <title>Test</title>
: <script type="text/javascript">
: function Add(){
: var txt = document.getElementById("textA").value;
: document.write(txt);
: }
: </script>
: </head>
: <body>
: <form id="form1" runat="server">
: <div>
: </div>
: </form>
: <input type="text" size="10" id="textA" />
: <input type="button" size="25" id="Check" value="Add" onclick="Add()" />
: </body>
: </html>
: ------------------------------------------------------------------------------
: 假如 我想要在 <script runat="server"> </script> 中
: 用一个 label 把javascript的txt印出来 要怎麽做?
: 虽然说网路上有很多说用 hidden?? 不过 真的不太懂 实作起来是怎麽样的写法 ~"~
: 麻烦高手帮一下 @_@"
不是高手路过回一下
我并不是完全懂你的意思 不过我"猜测"你可能需要的如下
在.aspx页面上放上<asp:Hidden ID="hf1"/>
在code behind中就可以用hf1.Value = "test";在server端指定值
这样子你的javascript就可以用var txt = hf1.value;来读取值
然後写到页面上
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.70.79.209
※ 编辑: pyrochlore 来自: 203.70.79.209 (10/21 03:23)
※ 编辑: pyrochlore 来自: 203.70.79.209 (10/21 03:24)