Note that there are some explanatory texts on larger screens.

plurals
  1. POASP CreateUserWizard Membership provider registration user validation
    text
    copied!<p>Im a newbie to the world of ASP and C#, I have just created my first Registration form using the CreateUserWizard Membership Provider and set up the validators which work great, Appart from the "Username". If the user name is taken the page simply refreshes and no error appears would be realy greatfull if somone could point out where I might be going wrong. </p> <p>Here is my current code :</p> <p><strong>SCRIPT</strong></p> <pre><code>protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { /* User is created and setting extra parameters to profile */ TextBox UserNameTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName"); string username = UserNameTextBox.Text; MembershipUser User = Membership.GetUser(username); umbraco.cms.businesslogic.member.Member member = new umbraco.cms.businesslogic.member.Member((int)User.ProviderUserKey); /* Here you can access properties for the member */ umbraco.cms.businesslogic.property.Property FullNameProperty = member.getProperty("fullname"); // Property alias TextBox FullNameTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FullName"); FullNameProperty.Value = FullNameTextBox.Text; Roles.AddUserToRole(CreateUserWizard1.UserName, "NuneatonMember"); } protected void CreateUserWizard1_ContinueButtonClick(object sender, EventArgs e) { Response.Redirect("/member-area.aspx"); } </code></pre> <p>CONTENT</p> <pre><code>&lt;form runat="server"&gt; &lt;asp:CreateUserWizard ID="CreateUserWizard1" OnContinueButtonClick="CreateUserWizard1_ContinueButtonClick" OnCreatedUser="CreateUserWizard1_CreatedUser" runat="server"&gt; &lt;WizardSteps&gt; &lt;asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server"&gt; &lt;ContentTemplate&gt; First Name :&lt;asp:TextBox Runat="server" ID="FullName" CssClass="user_info"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="FullNameVal" runat="server" ControlToValidate="FullName" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt; &lt;br/&gt; Last Name :&lt;asp:TextBox Runat="server" ID="LastName" CssClass="user_info"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="LastNameVal" runat="server" ControlToValidate="LastName" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt; &lt;br/&gt; Username :&lt;asp:TextBox Runat="server" ID="UserName" CssClass="user_info"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="UserNameVal" runat="server" ControlToValidate="UserName" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt; &lt;br/&gt; E-mail :&lt;asp:TextBox Runat="server" ID="Email" CssClass="user_info"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="EmailVal" runat="server" ControlToValidate="Email" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt; &lt;asp:RegularExpressionValidator id="valRegEx" runat="server" ControlToValidate="Email" ValidationExpression=".*@.*\..*" ErrorMessage="* is not a valid e-mail address." ValidationGroup="CreateUserWizard1" display="dynamic"&gt;&lt;/asp:RegularExpressionValidator&gt; &lt;br/&gt; Password :&lt;asp:TextBox Runat="server" ID="Password" CssClass="user_info"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="PasswordVal" runat="server" ControlToValidate="Password" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt; &lt;br/&gt; Confirm Password :&lt;asp:TextBox Runat="server" ID="ConfirmPassword" CssClass="user_info"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="PConfirmVal" runat="server" ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt; &lt;br/&gt; &lt;asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" Display="Dynamic" ValidationGroup="CreateUserWizard1" ErrorMessage="Foul: Password and Confirmation Password do not match. Fix them."&gt;&lt;/asp:CompareValidator&gt; &lt;asp:literal runat="server" enableviewstate="true" id="FailureText"&gt;&lt;/asp:literal&gt; &lt;/ContentTemplate&gt; &lt;/asp:CreateUserWizardStep&gt; &lt;asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server"&gt;&lt;/asp:CompleteWizardStep&gt; &lt;/WizardSteps&gt; &lt;/asp:CreateUserWizard&gt; </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload