示例#1
0
        protected void Page_Load(object sender, EventArgs e) {
            Feedback.Visible = false;
            
            Guid roleId;
            if (!Request.QueryString["id"].TryParseGuid(out roleId)) {
                ShowError(Feedback, "The parameter for id is not in the correct format!");
                SaveButton.Visible = false;
                FormFields.Visible = false;
                return;
            }

            _roleManager = IdentityRoleManager.GetManager();
            _role = _roleManager.FindById(roleId);

            if (_role == null) {
                ShowError(Feedback, "No role was found for the given id!");
                SaveButton.Visible = false;
                FormFields.Visible = false;
                return;
            }

            SaveButton.Click += SaveButton_Click;

            if (!IsPostBack) {
                RoleId.Value = roleId.ToString();
                RoleName.Text = _role.Name;

                if (Request.QueryString["message"] == "created") {
                    ShowMessage(Feedback, "Role has been created!");
                }
            }

            RenderUsersInRole();
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Feedback.Visible = false;

            Guid roleId;

            if (!Request.QueryString["id"].TryParseGuid(out roleId))
            {
                ShowError(Feedback, "The parameter for id is not in the correct format!");
                SaveButton.Visible = false;
                FormFields.Visible = false;
                return;
            }

            _roleManager = IdentityRoleManager.GetManager();
            _role        = _roleManager.FindById(roleId);

            if (_role == null)
            {
                ShowError(Feedback, "No role was found for the given id!");
                SaveButton.Visible = false;
                FormFields.Visible = false;
                return;
            }

            SaveButton.Click += SaveButton_Click;

            if (!IsPostBack)
            {
                RoleId.Value  = roleId.ToString();
                RoleName.Text = _role.Name;

                if (Request.QueryString["message"] == "created")
                {
                    ShowMessage(Feedback, "Role has been created!");
                }
            }

            RenderUsersInRole();
        }