|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 Admin_Users_Create_User : System.Web.UI.Page
{
System.Web.Security.MembershipCreateStatus status;
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
try
{
AddUser();
Response.Redirect("Default.aspx");
}
catch (Exception ex)
{
ConfirmationMessage.InnerText = "Insert Failure: " + ex.Message;
}
}
}
protected void Page_PreRender(object sender, EventArgs e)
{
UserRoles.DataSource = Roles.GetAllRoles();
UserRoles.DataBind();
}
protected void AddUser()
{
// Add User.
MembershipUser newUser = Membership.CreateUser(username.Text, password.Text);
//Membership.UpdateUser(newUser);
if (status == MembershipCreateStatus.Success)
{
ConfirmationMessage.InnerText = "User Created Successfully..";
}
// Add Roles.
foreach (ListItem rolebox in UserRoles.Items)
{
if (rolebox.Selected)
{
Roles.AddUserToRole(username.Text, rolebox.Text);
}
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
Response.Redirect("~/Admin/Users/Default.aspx");
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I love programming, reading, and meditation. I like to explore management and productivity.