急!请教关于Forms Authentication的问题
我以创建了一个CreateUserWizard的界面,点击create User之后,出现一个check Box ,有China,Sweden两个选择。
希望做出来的效果是勾选到China,自动设定他的角色就是China,不可以访问Sweden的页面。2个都勾选的话,角色就是Both,
就是2个页面都可以看到。
点击Create User 的代码是
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
。。。。。。。。。
Roles.AddUserToRole(CreateUserWizard1.UserName, "china");
。。。。。。。。。。。。。。。
}
不知道怎么写,可以让角色和用户名挂钩起来
选完check box之后,点击Finish Button,代码是
protected void CreateUserWizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{
Label lbl = (Label)CreateUserWizard1.CompleteStep.Controls[0].FindControl("lblSubscriptionList");
CheckBoxList chk = (CheckBoxList)CreateUserWizard1.FindControl("chkSubscription");
string selection = "";
foreach (ListItem item in chk.Items)
{
if (item.Selected) selection += "<br /> " + item.Text;
}
lbl.Text = selection;
}
会出现你选择的项目,点击Continue Button可以到主页相关信息。
protected void ContinueButton_Click(object sender, EventArgs e)
{
Response.Redirect("Default.aspx");
}
我已经在管理页面的网站上设定了相关的规则,就是不晓得怎么把注册的用户名和角色对上号,谢谢!