Welcome to ASP.NET Guild

Be sure to come back often and tell others. If you have any tips, tricks, examples, please email them to me at chris.williams@techguilds.com and I will post them. Check out our ASP.NET QuickStart and C# QuckStart Libraries. Below is my latest articles.

Monday, May 18, 2015

ASP.NET Bootstrap Template Quickstart - Part 2: Using Email Address as UserName

When you first generate your application, the registration page insists on a UserName and Email Address from your clients, however it is more common to reduce the number of fields the user has to fill in as it increases registration.  The Email Address is much more valuable than the UserName as you can interact with it.

There are a couple changes you must make to use Email Address as the UserName:
  1. Change the UserName field to Email Address.
  2. In the control open tag you must add RequiresEmail=false
    If you forget to set this you will get the error message: 

    RegisterUser: CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Email for the e-mail, this is required if RequireEmail = true.

  3. Next you will want to add a validator to your username field to ensure it is in email format.  There are a few ways to do it.  You can use the RegEx Validator as a minimum or extend it to do a DNS lookup depending on your needs. Below is a sample I got from a StackOverflow article:

    <asp:RegularExpressionValidator ID="regexEmailValid" runat="server" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="tbEmail" ErrorMessage="Invalid Email Format"></asp:RegularExpressionValidator>
If you have any tips, tricks or resources you would like to share with the guild email me at chris.williams@readwatchcreate.com

Are you a .NET Developer or Contractor interested in working with Sitecore or Dynamics CRM?

Apply for our Mentorship Program. If accepted, we will mentor you on Sitecore and provide you with project to help you build your skills and make some money at the same time. If you are interested send your resume with details on why you want to work with Sitecore or Dynamics CRM to: Chris Williams - chris.williams@techguilds.com or Dennis Augustine - dennis.augustine@techguilds.com We look forward to working with you to achieve your goals.