DDDD
DDDD

Reputation: 3940

Get the input from a form to display in textbox in the same web page

My form collecting input.

        <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>

I know this is set up for a server which I will work on next, right now I am just trying to get the btnsave button to display the input from the form into a plain textbox. How is this done?

Upvotes: 1

Views: 747

Answers (1)

Aristos
Aristos

Reputation: 66641

To do that on the code behind just use the Request.Form, contains all the form data in one line.

So your final code will be something like txtLiteral.Text = Request.Form.ToString()

Upvotes: 1

Related Questions