开发者

how to get id of a textbox with the signup control

开发者 https://www.devze.com 2023-02-28 22:06 出处:网络
im using the signup control that is within visual studio and im trying to get the id of textbox within so i can insert it in the database but in the code behind it wont recognize the id of the text bo

im using the signup control that is within visual studio and im trying to get the id of textbox within so i can insert it in the database but in the code behind it wont recognize the id of the text box. here is my signup aspx:

<asp:CreateUserWizard ID="mainSignUp" runat="server" 
    CreateUserButtonText="SignUp" FinishDestinationPageUrl="copyPastPage.aspx"
     ContinueDestinationPageUrl="~/copyPastPage.aspx"
     OnCreatedUser="redirect" LoginCreatedUser="true" 
    DuplicateEmailErrorMessage="e-mail already in use, enter a differnt email.">
    <CreateUserButtonStyle CssClass="signUpButton"  />
    <TextBoxStyle BorderStyle="None" Height="35px" 
        Width="200px" />
    <WizardSteps>
        <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server" >
            <ContentTemplate>
                <table>
                    <tr>
                        <td align="right">
                            <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Page Name:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="UserName" runat="server" BorderStyle="None" BorderWidth="1px" 
                                CssClass="signUpTextBox" Height="39px" Width="197px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
                                ControlToValidate="UserName" ErrorMessage="User Name is required." 
                                ToolTip="User Name is required." ValidationGroup="mainSignUp">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="Password" runat="server" BorderStyle="None" BorderWidth="1px" 
                                CssClass="signUpTextBox" Height="39px" TextMode="Password" Width="197px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" 
                                ControlToValidate="Password" ErrorMessage="Password is required." 
                                ToolTip="Password is required." ValidationGroup="mainSignUp">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <asp:Label ID="ConfirmPasswordLabel" runat="server" 
                                AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="ConfirmPassword" runat="server" BorderStyle="None" 
                                BorderWidth="1px" CssClass="signUpTextBox" Height="39px" TextMode="Password" 
                                Width="197px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" 
                                ControlToValidate="ConfirmPassword" 
                                ErrorMessage="Confirm Password is required." 
                                ToolTip="Confirm Password is required." ValidationGroup="mainSignUp">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="Email" runat="server" BorderStyle="None" BorderWidth="1px" 
                                CssClass="signUpTextBox" Height="39px" Width="197px"></asp:TextBox>
                            <asp:RequiredField开发者_如何学PythonValidator ID="EmailRequired" runat="server" 
                                ControlToValidate="Email" ErrorMessage="E-mail is required." 
                                ToolTip="E-mail is required." ValidationGroup="mainSignUp">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <asp:Label ID="Label1" runat="server" AssociatedControlID="EmailTextBox">E-mail(again):</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="EmailTextBox" runat="server" BorderStyle="None" BorderWidth="1px" 
                                CssClass="signUpTextBox" Height="39px" Width="197px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question">Security Question:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="Question" runat="server" BorderStyle="None" BorderWidth="1px" 
                                CssClass="signUpTextBox" Height="39px" Width="197px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="QuestionRequired" runat="server" 
                                ControlToValidate="Question" ErrorMessage="Security question is required." 
                                ToolTip="Security question is required." ValidationGroup="mainSignUp">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer">Security Answer:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="Answer" runat="server" BorderStyle="None" BorderWidth="1px" 
                                CssClass="signUpTextBox" Height="39px" Width="197px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="AnswerRequired" runat="server" 
                                ControlToValidate="Answer" ErrorMessage="Security answer is required." 
                                ToolTip="Security answer is required." ValidationGroup="mainSignUp">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" colspan="2">
                            <asp:CompareValidator ID="PasswordCompare" runat="server" 
                                ControlToCompare="Password" ControlToValidate="ConfirmPassword" 
                                Display="Dynamic" 
                                ErrorMessage="Password and Confirmation doesn't match." 
                                ValidationGroup="mainSignUp" CssClass="PasswordCompare" Width="300px" 
                                ></asp:CompareValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" colspan="2" style="color:Red;">
                            <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:CreateUserWizardStep>
        <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server" />
    </WizardSteps>
</asp:CreateUserWizard>

iam using asp.net 3.5 thanks


You have to use the FindControl method to find a particular control. I just tested this based on your design:

((TextBox)CreateUserWizardStep1.Controls[0].FindControl("UserName")).Text
0

精彩评论

暂无评论...
验证码 换一张
取 消