我有个button
protected void button1(object sender,eventargs e)
{
 Response.Write("<script language='javascript'> var tempA=window.prompt('请输入你的购买数量','')</script>");
}
点击下button,将会弹出一个对话框;并且你输入的数据会传递给tempA;
我想问问;如何在后台里面获得tempA的值;
假设我后台有个全局变量int i=0; 如何让i获得tempA;

解决方案 »

  1.   

    window.prompt只能返回到值 到input里面,需要再次提交,才能在.cs里面得到.
      

  2.   

    要把javascript的值传给后台,那就用ajax吧
      

  3.   

    能不能给我点提示。
    比如用到ajax哪些函数或者关键字。
    期待3楼进一步解答。
      

  4.   

     <script>
            function GetValue() {
                document.getElementById("<%=Hidden1.ClientID %>").value = window.prompt('请输入你的购买数量', '');
            }
        </script>.html
     <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" OnClientClick="GetValue()" />
            <input type=hidden id="Hidden1" runat=server />.cs
    Response.Write("刚才输入的值:"+this.Hidden1.Value.ToString());