如何使用相同的注册页面来管理配置文件以及新成员注册 [英] How can I use the same registration page for manage profile as well as for new member registration

查看:56
本文介绍了如何使用相同的注册页面来管理配置文件以及新成员注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用相同的编辑个人资料注册页面以及新会员注册..现在一切正常但当我点击添加新会员时,它将打开填充用户数据的页面(即管理个人资料页面)建议我应该在页面加载时编写什么代码,以便系统可以在必须加载管理个人资料页面时以及添加成员页面时



我尝试过:



protected void page_load(object sender,EventArgs e)

{

#region

if(!IsPostBack)

{

if(Session [UserID]!= null)

{

尝试

{

int UserId = Convert.ToInt32(Session [UserID]);

FillUserData(UserId);

}

cat ch(例外)

{



throw;

}

}

else

{

Response.Redirect(MemberRegister.aspx);





}

BindUserType();

BindState();

BindPackage();

}

#endregion

}

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
}

推荐答案

通常你传递记录的ID在查询字符串中编辑(或将其存储在会话中),如果该ID存在,那么它是表单的编辑版本,但如果它不存在那么它就是添加新版本。



所以对于像
这样的网址


member.aspx?id = 123





代码将为冷杉检查当前用户是否为用户123,如果是,则编辑用户123,以便在表单中显示用户123的详细信息。如果网址是



member.aspx



那么它假设它正在添加一个新成员所以显示一个空白表格。



如果您无法在查询字符串上传递当前用户的ID,您可以执行其他操作,例如



member.aspx?id = me



如果id是我,则编辑当前用户,如果是id是数字然后编辑该用户(如果当前用户有权),否则添加新用户。
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.


这篇关于如何使用相同的注册页面来管理配置文件以及新成员注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆