Auto generate Username

nahunter

Newcomer
Joined
Apr 17, 2003
Messages
3
Location
Wilton, CT
Hello everyone,
I am quite new to the whole .NET scene and I was wondering if there is a piece of code that would autogenerate a username based on what the user enters for their first name and last name. Something to the effect of that would show up in a textbox that is grayed out of first initial and full last name. Thanks in advance.
Norm
 
Obtain the first initial of the first name my using the substring method of the string class - e.g. txtForname.Text.Substring(1,1)

Combine first and last name by using the concatenation method - e.g. sUsername = String.Concat(txtForname.Text.Substring(1,1), txtSurname.Text)

Hope this is of some help!
 
nibsy said:
Obtain the first initial of the first name my using the substring method of the string class - e.g. txtForname.Text.Substring(1,1)

Combine first and last name by using the concatenation method - e.g. sUsername = String.Concat(txtForname.Text.Substring(1,1), txtSurname.Text)

Hope this is of some help!

Nibsy,
Thanks you for that and your quick response.

Norm
 
Let me get this straight

So if I have '<asp:textbox id="UserName" runat="server" BackColor="LightBlue" BorderColor="Black"></asp:textbox>', and my First Name text box is labeled 'FirstName' and my Last Name text box is labeled 'LastName' then I should have the code as

txtFirstName.Text.Substring(1,1) , and to combine it would be
sUsername = String.Concat (txtFirstName.Text.Substring(1,1), txtLastName.Text) ?

Im not sure how what I have currently above fits with what you said. Please bear with me as I said I am a newbie on asp.net. Thanks for your help
 
Back
Top