0

我使用了一些访问文本的变体,StreetNbrtxt包括

1) Directly: Profile.StreetNbr = StreetNbrtxt.Text; (Didn't work)
2) Using FindControl: Profile.StreetNbr = ((TextBox)RegisterUserWizardStep.FindControl("StreetNbrtxt")).Text; ('Not a instantiated class' Error message)

此外,我无法看到我在文本框中添加的值,这些文本框被添加到 Visual Studio Express 2012 的 Account 文件夹中的预编码文件中。

我从 Register.aspx 获得的代码如下:

    <asp:CreateUserWizard runat="server" ID="RegisterUser" ViewStateMode="Disabled" OnCreatedUser="RegisterUser_CreatedUser" ActiveStepIndex="0">
    <LayoutTemplate>
        <asp:PlaceHolder runat="server" ID="wizardStepPlaceholder" />
        <asp:PlaceHolder runat="server" ID="navigationPlaceholder" />
    </LayoutTemplate>
    <WizardSteps>
        <asp:CreateUserWizardStep runat="server" ID="RegisterUserWizardStep">
            <ContentTemplate>
                <p class="message-info">
                    Passwords are required to be a minimum of <%: Membership.MinRequiredPasswordLength %> characters in length.
                </p>

                <p class="validation-summary-errors">
                    <asp:Literal runat="server" ID="ErrorMessage" />
                </p>

                <fieldset>
                    <legend>Registration Form</legend>
                    <ol>
                        <p>
                            <asp:Label runat="server" AssociatedControlID="UserName">User name</asp:Label>
                            <asp:TextBox runat="server" ID="UserName" />
                            <asp:RequiredFieldValidator runat="server" ControlToValidate="UserName"
                                CssClass="field-validation-error" ErrorMessage="The user name field is required." />
                        </p>
            :
            :
            :
            :
            :
                        <p>
                            <asp:Label ID="StreetNumberlbl" runat="server" AssociatedControlID="StreetNbrtxt">Street Number:</asp:Label>
                            <asp:TextBox ID="StreetNbrtxt" runat="server" CssClass="style11"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="StreetNbrtxt"
                                CssClass="failureNotification" ErrorMessage="A street address number is required" ToolTip="Please insert your home address number"
                                ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                        </p>    
                    </ol>               
        <asp:Button runat="server" CommandName="MoveNext" Text="Register" />
         </fieldset>
            </ContentTemplate>

关于我应该如何从用户输入文本框中访问街道号码的任何想法?

4

1 回答 1

0

CreateUserWizard控制是基于Wizard控制的,控制是有步骤的。因此,您需要在步骤中找到控件。就您而言,这是第一步。您可以像这样访问控件。

TextBox StreetNbrtxt = 
(TextBox)RegisterUser.WizardSteps[0].
FindControl("CreateUserStepContainer").FindControl("StreetNbrtxt");

你可以看看它是如何工作的。我希望这对你也有用,因为它对我有用很长时间。谢谢!

编辑:这是官方网站上有关向导控制的更多阅读链接。

于 2016-08-15T04:33:54.487 回答