如何在CreateUserwizard中添加新的文本框控件 [英] How to add new textbox control in CreateUserwizard

查看:57
本文介绍了如何在CreateUserwizard中添加新的文本框控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.NET网页的第一步注册新的CreateUserWizard中添加了一个名为NameTextBox的文本框。我保存了页面。



现在,当我转到该网页后面的CSharp代码时,它表示控件NameTextBox不存在于当前内容中。我检查了所有。不知道问题出在哪里。



有人可以帮忙吗?







以下是代码..



I added a textbox with name ''NameTextBox'' in the first step "Sign up for your new" of CreateUserWizard on my ASP.NET webpage. i saved the page.

now, when i goes to the CSharp code behind that webpage, it says that the control NameTextBox doesnot exists in the current content. I checked all. Not sure where is the problem.

Can somebody help??



Here is the code..

<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" BackColor="#F7F7DE" 

            BorderColor="#CCCC99" BorderStyle="Solid" BorderWidth="1px" 

            Font-Names="Verdana" Font-Size="10pt" Width="327px">
            <ContinueButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 

                BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 

                ForeColor="#284775" />
            <CreateUserButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 

                BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 

                ForeColor="#284775" />
            <TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" />
            <WizardSteps>
                <asp:CreateUserWizardStep runat="server">
                    <ContentTemplate>
                        <table style="font-family:Verdana;font-size:100%;width:327px;">
                            <tr>
                                <td align="center" colspan="2" 

                                    style="color:White;background-color:#6B696B;font-weight:bold;">
                                    Sign Up for Your New Account</td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="UserName" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 

                                        ControlToValidate="UserName" ErrorMessage="User Name is required." 

                                        ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</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" TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" 

                                        ControlToValidate="Password" ErrorMessage="Password is required." 

                                        ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</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" TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" 

                                        ControlToValidate="ConfirmPassword" 

                                        ErrorMessage="Confirm Password is required." 

                                        ToolTip="Confirm Password is required." ValidationGroup="CreateUserWizard1">*</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"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="EmailRequired" runat="server" 

                                        ControlToValidate="Email" ErrorMessage="E-mail is required." 

                                        ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </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"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="QuestionRequired" runat="server" 

                                        ControlToValidate="Question" ErrorMessage="Security question is required." 

                                        ToolTip="Security question is required." ValidationGroup="CreateUserWizard1">*</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"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="AnswerRequired" runat="server" 

                                        ControlToValidate="Answer" ErrorMessage="Security answer is required." 

                                        ToolTip="Security answer is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="NameLabel" runat="server">Name:</asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="NameTextBox" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 

                                        ControlToValidate="NameTextBox" ErrorMessage="*"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="RoleLabel" runat="server">Role:</asp:Label>
                                </td>
                                <td>
                                    <asp:DropDownList ID="RoleDropDownList" Width="128px" Height="22px" runat="server">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2">
                                    <asp:CompareValidator ID="PasswordCompare" runat="server" 

                                        ControlToCompare="Password" ControlToValidate="ConfirmPassword" 

                                        Display="Dynamic" 

                                        ErrorMessage="The Password and Confirmation Password must match." 

                                        ValidationGroup="CreateUserWizard1"></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 runat="server" />
            </WizardSteps>
            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" 

                HorizontalAlign="Center" />
            <NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 

                BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 

                ForeColor="#284775" />
            <SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" 

                ForeColor="#FFFFFF" />
            <SideBarStyle BackColor="#7C6F57" BorderWidth="0px" Font-Size="0.9em" 

                VerticalAlign="Top" />
            <StepStyle BorderWidth="0px" />
        </asp:CreateUserWizard>











The C# server code i used is








The C# server code i used is

RolesDropDownList.Items.Clear();

推荐答案

Best guess (based on the code fragment you posted - i.e. none) you forgot to add runat=\"server\" to the definition.



Tin foil hat replaced.
Best guess (based on the code fragment you posted - i.e. none) you forgot to add runat="server" to the definition.

Tin foil hat replaced.


maybe try this

maybe try this
TextBox name = (TextBox)RegisterUser.CreateUserStep.FindControl("name");


这篇关于如何在CreateUserwizard中添加新的文本框控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆