1

我的表单收集输入。

        <table>
       <tr>
         <td>First Name:</td>
         <td><asp:TextBox ID="txtFirstName" runat="server">
            </asp:TextBox>
         </td>
         <td class="style2"><asp:RequiredFieldValidator ID="rfvFirstName" 
                     runat="server" 
                     ControlToValidate="txtFirstName"
                    ErrorMessage="First Name can't be left blank" 
                    SetFocusOnError="True">*
             </asp:RequiredFieldValidator>
             <asp:DropDownList ID="DropDownList1" runat="server">
             <asp:ListItem>Business</asp:ListItem>
             <asp:ListItem>Other</asp:ListItem>
             </asp:DropDownList>
        </td>
        </tr>
        <tr>
        <td>Last Name:</td>
        <td><asp:TextBox ID="txtLastName" runat="server">
            </asp:TextBox></td>
        <td class="style2"><asp:RequiredFieldValidator 
                 ID="RequiredFieldValidator1" runat="server" 
                 ControlToValidate="txtLastName"
                 ErrorMessage="Last Name can't be left blank" 
                 SetFocusOnError="True">*
            </asp:RequiredFieldValidator>
        </td></tr>

        <tr><td>UserName:</td>
        <td><asp:TextBox ID="txtUserName" runat="server">
            </asp:TextBox>
        </td>
        <td class="style2"><asp:RequiredFieldValidator 
                 ID="rfvUserName" 
                 runat="server" 
                 ControlToValidate="txtUserName"
                 ErrorMessage="UserName can't be left blank" 
                 SetFocusOnError="True">*
            </asp:RequiredFieldValidator>
        </td></tr>

        <tr><td>Password:</td>
        <td><asp:TextBox ID="txtPwd" runat="server"
                         TextMode="Password">
            </asp:TextBox>
        </td>
        <td class="style2"><asp:RequiredFieldValidator ID="rfvPwd" 
                 runat="server" ControlToValidate="txtPwd"
                 ErrorMessage="Password can't be left blank" 
                 SetFocusOnError="True">*
           </asp:RequiredFieldValidator>
        </td></tr>

        <tr><td>Confirm Password:</td>
        <td><asp:TextBox ID="txtRePwd" runat="server"
                         TextMode="Password">
            </asp:TextBox>
        </td>
        <td class="style2"><asp:CompareValidator ID="CompareValidator1" 
                 runat="server" 
                 ControlToCompare="txtRePwd" 
                 ControlToValidate="txtPwd" 
                 Operator="Equal" 
                 ErrorMessage="Password and confirm password do not match" 
                 SetFocusOnError="True">
            </asp:CompareValidator>
        </td></tr>

        <tr><td class="style1">Gender:</td>
        <td class="style1"><asp:RadioButtonList ID="rdoGender" 
                                 runat="server">
                 <asp:ListItem>Male</asp:ListItem>
                 <asp:ListItem>Female</asp:ListItem>
            </asp:RadioButtonList>
        </td>
        <td class="style3"><asp:RequiredFieldValidator 
                 ID="RequiredFieldValidator2" 
                 runat="server" 
                 ControlToValidate="rdoGender"
                 ErrorMessage="Gender can't be left blank" 
                 SetFocusOnError="True">*
             </asp:RequiredFieldValidator>
        </td></tr>

        <tr><td>Address:</td>
        <td><asp:TextBox ID="txtAdress" runat="server" 
                         TextMode="MultiLine">
            </asp:TextBox>
        </td>
        <td class="style2"><asp:RequiredFieldValidator ID="rfvAddress" 
                runat="server" 
                 ControlToValidate="txtAdress"
                ErrorMessage="Address can't be left blank" 
               SetFocusOnError="True">*
            </asp:RequiredFieldValidator>
        </td></tr>
        <tr><td>Email ID:</td>
        <td><asp:TextBox ID="txtEmailID" runat="server">
            </asp:TextBox>
        </td>
        <td class="style2"><asp:RequiredFieldValidator 
                ID="RequiredFieldValidator3" 
                runat="server" 
                ControlToValidate="txtEmailID"
                ErrorMessage="Email can't be left blank" 
                SetFocusOnError="True">*
           </asp:RequiredFieldValidator>
       </td></tr>
       <tr><td><asp:Label ID="lblMsg" runat="server">
               </asp:Label>
          </td>
       <td><asp:ValidationSummary ID="ValidationSummary1" 
                runat="server" ShowMessageBox="True" 
                ShowSummary="False"/>
       </td></tr>
       <tr><td><asp:Button ID="btnSave" runat="server" 
                       Text="Sign Up" 
                       onclick="btnSave_Click"/>
   </td></tr>
   </table>

我知道这是为我接下来要工作的服务器设置的,现在我只是想获取 btnsave 按钮以将表单中的输入显示到纯文本框中。这是怎么做到的?

4

1 回答 1

1

要在后面的代码上执行此操作,只需使用Request.Form, 将所有表单数据包含在一行中。

所以你的最终代码将类似于txtLiteral.Text = Request.Form.ToString()

于 2013-03-03T00:06:01.780 回答