Click here to Skip to main content
16,018,653 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the same registration page for Edit Profile as well as for new Member registration..now everything is working properly but when i am clicking on "Add new member" it will open the "page with filled user data"(i.e manage profile page) suggest me what code should i write on page load so that system could differentiate when it has to load manage profile page and when "Add member page

What I have tried:

protected void page_load(object sender, EventArgs e)
{
#region
if (!IsPostBack)
{
if(Session["UserID"]!=null)
{
try
{
int UserId = Convert.ToInt32(Session["UserID"]);
FillUserData(UserId);
}
catch (Exception)
{

throw;
}
}
else
{
Response.Redirect("MemberRegister.aspx");


}
BindUserType();
BindState();
BindPackage();
}
#endregion
}
Posted
Updated 22-Sep-16 0:52am
Comments
Vincent Maverick Durano 22-Sep-16 7:35am    
What is "Add new Member"? was it a link from other page? or a button on the same page where you write the code in page load?
Member 12749751 22-Sep-16 9:14am    
Sir..Its Done.Don't worry
MSagar007 28-Sep-16 6:49am    
Refer the below give you might get some hint

http://www.c-sharpcorner.com/article/crud-in-single-view/

1 solution

Usually you pass the ID of the record to edit in the querystring (or store it in the session) and if the ID exists then it is the "edit" version of the form, but if it doesn't exist then it's the "add new" version.

So for a url like

member.aspx?id=123


the code will first check that the current user is user 123 and if they are then edit user 123 so show user 123's details in the form. If the url is

member.aspx

then it assumes it is adding a new member so shows a blank form.

If you aren't in a position to pass the current user's ID on the querystring you could do something else like

member.aspx?id=me

and if the id is "me" do an edit of the current user, if id is numeric then edit that user (if the current user has rights to), otherwise add a new user.
 
Share this answer
 
Comments
Member 12749751 22-Sep-16 7:02am    
I am not using query string instead of that i have already created a session for that logged in user and on edit profile i am displaying his user details but that user wants to add a new user so that time how can he get an access to blank registration page
F-ES Sitecore 22-Sep-16 7:07am    
You're going to have to put something on the querystring that lets the page know whether to edit or add. Easiest given what you have already is probably to add something to the querystring when you want to add. But you're going to have to do *something*, you can't introduce new functionality without writing code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900