 |
| ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Professional 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
|
|
|
|

June 27th, 2007, 02:12 PM
|
|
Authorized User
|
|
Join Date: Jun 2007
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ASp.net 2.0 login name control
Hi, I m using the login name control to display a welcome message once the user is logged in.
Currently it displays the username that the user enters in the username text box of login control.
I want to be able to use the First Name and Last Name as welcome login text. How can I do this?
|
|

June 27th, 2007, 02:26 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
You can't do that directly with the LoginName control. You can set the FormatString property to customize the welcome text a but, bit it will always display the user name.
You can, however, use a LoginView control with a LoggedInTemplate that only shows for logged in users like this:
Code:
<asp:LoginView ID="LoginView1" runat="server">
<LoggedInTemplate>
Hi there:
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</LoggedInTemplate>
</asp:LoginView>
Then from the code behind you can set the text of the label. You need to use FindControl on the LoginView to find the label first.
First name and last names are not available out of the box. Look into [ur="http://quickstarts.asp.net/QuickStartv20/aspnet/doc/profile/default.aspx"l]ASP.NET Profiles[/url] for some ideas about storing user specific data.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
|

June 27th, 2007, 07:11 PM
|
|
Authorized User
|
|
Join Date: Jun 2007
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you Sir,
Well, I am trying to avoid using profile provider for personal information since my application would be need FirstName or DepartmentName to query the database.
So now, I have two options.
In database,
1. Either add columns to existing membership table
2. Or Create a new custom table to store personal information.
In CreateWizard control,
1. Either add new fields to the Sign In step (Overload the CreateUser function to take in additional parameters, I will also have to implement custom MmembershipUser class to accomodate extra information.
2.Or Create a new Wizard Step
On Finish of this step , save the data to your custom personal information table.
I am really confused about which approach is the better one..!
Could you please suggest me something on this.
Will I be safe If I take approach 2.
Really appreciate your help.
Thanks,
--Monika
|
|

June 28th, 2007, 04:22 PM
|
|
Authorized User
|
|
Join Date: Jun 2007
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you very much.
One quick question regarding CreateUserWizard Control.
I am not able to customize the "Create User" button.
What to do if I want to change the Text of that button to say "Register".
Also, a click on "Create User" button makes a call to Membership.CreateUser. Is there a way I can make this function call my overloaded CreateUser function.?
Sorry if I sound really stupid.
--Monika
|
|

June 28th, 2007, 04:33 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
|
quote:I am not able to customize the "Create User" button.
|
Have you looked at the CreateUserButtonText property?
Quote:
|
quote:Is there a way I can make this function call my overloaded CreateUser function.?
|
Handle the CreatingUser event of the control and call whatever you want. Then set e.Cancel = true to prevent the ASP.NET runtime from doing its own thing.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
|

June 28th, 2007, 05:27 PM
|
|
Authorized User
|
|
Join Date: Jun 2007
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
I tried to handle it in CreatingUser event of CreateUserWizard
But the EventArgs e does not have a Cancel property with e.
|
|

June 29th, 2007, 01:17 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
How does your code look? The CreatingUser event does have an e argument that exposes a Cancel property. Normal EventArgs don't, but the LoginCancelEventArgs do.
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
|

June 29th, 2007, 02:27 PM
|
|
Authorized User
|
|
Join Date: Jun 2007
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
My code was liked this.
protected void CreateUserWizard1_CreatingUser(object sender, EventArgs e)
I copy-pasted the CreatedUser event and just changed the name to CreatingUser and hence this mistake.
Now , I have changed the EventArgs parameter to LoginCancelEventArgs and now it works.... Thanks a lot.!
Is there anyway, that Visual Studio 2005 will automatically add stubs for the event handlers that I need to implement.
The way I m doing right now is I check the supported events from intellisense and then go in msdn to find the signature for that and write it according in my code.
Any , better way of doing this?
|
|

June 29th, 2007, 04:08 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Yes there is. Select the control in Design View, press F4 to open up the Properties grid, click the button with the lightning bolt to switch to Event mode and double-click the event of your choice.
VS will add the method stub for you.
Cheers.
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
|
 |