请教各位老师
   我在前台里面  放了两个 客户端的text 和一个客户端的button
 现在点了这个button后要获取这两个text的value 去跟数据库匹配 登陆 也就是帐号密码。
   现在我已经获取到这两个value  那么要怎么通过后台接收呢?因为button 也是客户端的
     
   请各位老师能给出详细代码。
      或者其他的思路
万分感谢

解决方案 »

  1.   

    string s=Resquest.params["控件的ID"].toString();
      

  2.   

    既然要回发到服务器端,为什么不用服务器控件的Button呢?
      

  3.   

    前台:
    <form action="test.aspx" method="post">
      <input type="text1" value="">
    <input type="text2" value="">
    <input type="submit" value="提交">
    </form>后台: test.aspx.cspublic page_load()
    {
        if(!isPostBack)
        {
           string s1=Request.Form["text1"];
          string s2=Request.Form["text2"];
         下面你自己处理就可以了。
       }
    }
      

  4.   

    更改一下:
     <input type="text1" value=""> 
    <input type="text2" value="">  <input type="text" name="text1" value=""> 
    <input type="text"  name="text2" value=""> 
      

  5.   

    用服务器端控件啊 或者加上runat="server"
      

  6.   

    因为是用js产生的一个登陆效果页面
      而这个js里面直接用服务器控件 导致报错 一直说我 没有放在runat=server 下 
     我给head加 和每一个td tr 和div 都加了runat=server 依然说我没放在run=server的容器下messContent="<div style='padding:10px; width:300px;text-align:center;'>用户名:<input style='height:16px;width:100px;' name='用户名' type='text' value='' title='请输入用户名'></div><div style='padding:10px 10px 20px 10px;width:300px;text-align:center;'>密&nbsp;&nbsp;码:<input name='口令' style='height:16px;width:100px;' type='password' title='请输入口令'></div><div style='width:300px;text-align:center;padding:10px;'><input name='登陆' type='button' value='登陆' style='margin-right:15px; margin-left:15px;'><input name='现在注册' type='button' value='现在注册' style=' background:#fff; border:0px solid #fff;cursor:hand;'></div>";
      

  7.   

    测试通过       <input type="text" name="text1" value="">
           <input type="text"  name="text2" value=""> 
           <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
            protected void Button1_Click(object sender, EventArgs e)
            {
                string s1 = Request.Form["text1"];
                string s2 = Request.Form["text2"];
                string s = s1 + s2;
            }
      

  8.   

    回9楼 
    说了
     button 也是客户端的
      

  9.   

    有没有放到
    <from>
    </form>
    里面?
      

  10.   

    没有放到form里面
      因为是写在 asxc控件里面的 如果写了form 
     那么其他页面不能引用了
      

  11.   

    调用页面的<form> 有没有 runat="server"
      

  12.   

    <input type="text" name="text1" value="账号">
                        <input type="text" name="text2" value="密码">
                        <input type="button" runat="server" name="sybmit" text="Button" onclick="javascript:return checkuser();" /> <script>
            function checkuser()
            {
                var str = (页面的Inherits值).GetIsTrue(document.getElementById("text1").value,document.getElementById("text2").value);
                if (str != "true")
                    return false;
            }
        </script>
     Ajax.Utility.RegisterTypeForAjax(typeof(页面的Inherits值));//引用
    [Ajax.AjaxMethod()]
        public static string GetIsTrue(string aa, string bb)
        {
            UserPeople nmm_UserPeople = new UserPeople();
            DataSet ds = nmm_UserPeople.GetDataSetUserPeople(" and username='" + aa + "' and password='" + bb + "'");
            if (ds.Tables[0].Rows.Count > 0)
                return "true";
            else
                return "false";
        }
      

  13.   

    你要注意的是 你要把Ajax.dll 放入bin目录,Web文件中加入这样一句话
    <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax"/>经常不用让我自己也复习了下。