Re: [問題] javascript 與 ASP.NET

看板Ajax作者 (患得患失)時間15年前 (2008/10/21 03:23), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《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)
文章代碼(AID): #18_DgLLl (Ajax)
文章代碼(AID): #18_DgLLl (Ajax)