我想当点击 input 的时候向数据库插入数据。

解决方案 »

  1.   

    加上runat="server" 后台添加方法
      

  2.   

    没有 RUN  SEVER?? 没有后台操作的普通JS能操作db 吗?
      

  3.   

    想用JS的话就建个.ashx把方法写里面,然后再用JS调用就可以不用在底层写一行代码。
      

  4.   

    可以的话帮我写一个js掉用input事件的方法
      

  5.   

    页面放一个     <asp:ScriptManager ID="ScriptManager1"  runat="server" EnablePageMethods="True" />
     <img src="images/upinfo.gif"  border="0" onclick="UpdateOrderInfo();" style="cursor:pointer" /> 
    然后     PageMethods.UpdateOrderInfo($('txtCity').value,  Result);
    function Result(res) {
        if (res == "Access")
            window.location.href = "GouWuCheTwo.aspx";
        else
            window.location.href = "DengLu.aspx?url=" + document.URL;
    }
    后台写
      [System.Web.Services.WebMethod]
            public static string UpdateOrderInfo(string city)
            {
                if ()//成功
                 { return "Access";  }
                 else
                 { return "NoAccess";}
            }
      

  6.   

    post提交,直接在后台 接受数据就行了  Request.Form["name"];
      

  7.   

    可以另写一个aspx文件来插入,跟php那种类似
    <form id="form1" name="form1" method="post" action="Add.aspx">比如说上面那行代码,你就可以在add.aspx上面插入就行了