📄 register.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class register_aspx : Page
{
protected void CreateUserWizard1_ContinueButtonClick(object sender, EventArgs e)
{
Response.Redirect("~/default.aspx");
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CreateUserWizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
{
//如果当前向导页为向导开始页。ID值为WizardStep2
if (CreateUserWizard1.ActiveStep.ID == "WizardStep2")
{
//查找TextBox1文本框。
TextBox t = ((TextBox)CreateUserWizard1.ActiveStep.FindControl("TextBox1"));
//在视图状态中存储文本框中的值。
ViewState["Name"]=t.Text;
//查找TextBox2的文本框。
t = ((TextBox)CreateUserWizard1.ActiveStep.FindControl("TextBox2"));
//在视图状态中存储文本框中的值。
ViewState["Msn"]=t.Text;
}
//如果当前向导页为选择角色页面。
if (CreateUserWizard1.ActiveStep.ID == "WizardStep1")
{
//使用Membership静态类的GetuUser方法获取在用户注册窗口中己注册的用户。
MembershipUser objUser = Membership.GetUser();
//找到DropDownList1.
DropDownList ddl = ((DropDownList)CreateUserWizard1.ActiveStep.FindControl("DropDownList1"));
if (ddl != null)
{
//使用Roles静态类的AdduserToRole方法将当前用户添加到所选择的角色中。
Roles.AddUserToRole(objUser.UserName, ddl.SelectedValue);
}
//--------------------------------------------
//添加用户个性化信息。
Profile.UserName = objUser.UserName;
Profile.Email = objUser.Email;
Profile.Name=ViewState["Name"].ToString();
Profile.MSN=ViewState["Msn"].ToString();
//组属性使用Profile.组名.属性名进行访问
Profile.JobSeeker.ResumeID = -1;
Profile.Employer.CompanyID = -1;
}
}
protected void CreateUserWizard1_ActiveStepChanged(object sender, EventArgs e)
{
//如果当前页面为选择角色的步骤。
if (CreateUserWizard1.ActiveStep.ID == "WizardStep1")
{
//从当前活动步骤中查找到这个DropDownList控件。
DropDownList ddl = ((DropDownList)CreateUserWizard1.ActiveStep.FindControl("DropDownList1"));
if (ddl != null)
{
//添加角色,并将ListItem的值设为在Web.Config的appSetting节定义的角色名称。
ListItem li1 = new ListItem("求职者", ConfigurationManager.AppSettings["jobseekerrolename"]);
ListItem li2 = new ListItem("雇主", ConfigurationManager.AppSettings["employerrolename"]);
ddl.Items.Add(li1);
ddl.Items.Add(li2);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -