Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 11th, 2006, 12:14 PM
Authorized User
 
Join Date: May 2005
Location: Manchester, , United Kingdom.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Change user name option

Chapter 9 (great book)

Hi

How difficult is it to do away with the username option in create user, and have the email as the username/login instead? would be grateful for any advice

Thanks

  #2 (permalink)  
Old October 11th, 2006, 12:52 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi jackandjo,

Glad you like the book.

I think it's pretty easy to do. Here are the first steps to get you going:

1. Add a CreateUserWizard to a page.

2. Right-click it and choose Customize Create User Step

3. In the markup that has been added, add runat="server" and visible="false" attributes to the table row that holds the box for the User Name, like this:
Code:
<tr runat="server" visible="false">
  <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>
If you just remove the entire row, you'll get an error because the UserName field is required.

Then in the CreatingUser event, sync the user name and e-mail address like this:
Code:
Protected Sub CreateUserWizard1_CreatingUser(ByVal sender As Object, _
      ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs) _
      Handles CreateUserWizard1.CreatingUser
  CreateUserWizard1.UserName = CreateUserWizard1.Email
End Sub
This way, when the user is inserted, the e-mail address is inserted as the user's name.

Similar to this, you'll need to customize other controls; you mainly need to alter the labels in front of controls, similar to what's been done to the PasswordRecovery control in chapter 9 - The Web Shop.

Hope this helps and if not, please let me know.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Glass by Joy Division (Track 2 from the album: Heart And Soul (CD 1)) What's This?
  #3 (permalink)  
Old October 11th, 2006, 03:19 PM
Authorized User
 
Join Date: May 2005
Location: Manchester, , United Kingdom.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks very much, I will give it a go.

  #4 (permalink)  
Old October 11th, 2006, 03:40 PM
Authorized User
 
Join Date: May 2005
Location: Manchester, , United Kingdom.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Worked a treat.

Cheers



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Check Boxes/Option buttons/Option Group hewstone999 Access VBA 1 March 14th, 2008 07:25 AM
PrintPreviewDialog1. Change printer option peterasimpson VB How-To 0 July 24th, 2006 06:44 AM
Adding an option to change password to movie db IP076 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 November 30th, 2004 01:08 PM
How i can Change ADCL so that only 1 user can gakhar Pro VB 6 0 April 14th, 2004 01:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.