accessing userid immediately after creating the user in

Posted on 2011-09-22
Last Modified: 2012-05-12
I want to get the userid of the created user in the same page (infact create user page) immediately after creating the user. How can i do that? Please help me.
Thanks in advance
Question by:CPSRI

Expert Comment

ID: 36579820
You need to check the insert procedure of creating user,

in Sql
after insert if your userid column is auto increment value then write after the insert statement


and in your Data Acess
use ExecuteNONQuery to retrieve the inserted(user Id)  value.

LVL 15

Expert Comment

ID: 36579831
from the stored procedure you can return the user record after inserting to the table
use select f1,f2.f3 from users where id= SCOPE_IDENTITY()

Accepted Solution

guramrit earned 500 total points
ID: 36579865
There should be a CreateUserWizard control on page. Add handler to "OnCreatedUser" event, say "CreateUserWizard1_OnCreatedUser". CreateUserWizard1_OnCreatedUser event will be fired when user is created.
Now in this function you can access just created username using property CreateUserWizard1.UserName,
see following code:


<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" OnCreatedUser=CreateUserWizard1_OnCreatedUser>

code behind:
    protected void CreateUserWizard1_OnCreatedUser(object sender, EventArgs e)
        var uname = CreateUserWizard1.UserName;
        // do something...
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center


Author Comment

ID: 36579875
hey, i am so excited to meet you both again here, thanks for your replies but i want to access it in my page using c# code, and i am using membership class to create user. i can get the solution if you tell me exactly which stored procedure will be used to create user, in my case, using Membership class.

Expert Comment

ID: 36582014
If you are using Membership class, then you'll be using Membership.CreateUser to create user.
This function returns MembershipUser, which contains all the properties of newly created user.

MembershipUser user = Membership.CreateUser("testuser", "testpassword");
lblUser.Text = "Hello " + user.UserName;

Author Closing Comment

ID: 36582773
Thank you

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to refer to value 8 62 mvc5 6 23
asp Google Map 2 32
I need help adding validation to my MVC.Net view 6 10
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question