1 // Mainsoft.Web.AspnetConfig - Site AspnetConfig utility
\r
2 // (C) 2006 Mainsoft Corporation (http://www.mainsoft.com)
\r
3 // Permission is hereby granted, free of charge, to any person obtaining
\r
4 // a copy of this software and associated documentation files (the
\r
5 // "Software"), to deal in the Software without restriction, including
\r
6 // without limitation the rights to use, copy, modify, merge, publish,
\r
7 // distribute, sublicense, and/or sell copies of the Software, and to
\r
8 // permit persons to whom the Software is furnished to do so, subject to
\r
9 // the following conditions:
\r
11 // The above copyright notice and this permission notice shall be
\r
12 // included in all copies or substantial portions of the Software.
\r
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
17 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
18 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
19 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
24 using System.Configuration;
\r
25 using System.Collections;
\r
27 using System.Web.Security;
\r
28 using System.Web.UI;
\r
29 using System.Web.UI.WebControls;
\r
30 using System.Web.UI.HtmlControls;
\r
32 namespace Mainsoft.Web.AspnetConfig
\r
34 public partial class CreateUser : System.Web.UI.Page
\r
36 protected override void OnPreRender (EventArgs e)
\r
38 roles_lst.DataBind ();
\r
39 base.OnPreRender (e);
\r
40 if (CreateUserWizard1.ActiveStepIndex != 0) {
\r
41 text_lbl.Visible = false;
\r
42 ((Button) Master.FindControl ("Back")).Visible = false;
\r
43 active_chb.Enabled = false;
\r
47 protected void Page_Load (object sender, EventArgs e)
\r
50 roles_lst.DataValueField = "Role";
\r
51 roles_lst.DataSource = RolesDS.Select ();
\r
53 CreateUserWizard1.CreatingUser += new LoginCancelEventHandler (CreateUserWizard1_CreatingUser);
\r
54 CreateUserWizard1.CreatedUser += new EventHandler (CreateUserWizard1_CreatedUser);
\r
55 Button bt = Master.FindControl ("Back") as Button;
\r
57 bt.PostBackUrl = "Default.aspx";
\r
61 public void CreateUserWizard1_CreatedUser (object sender, EventArgs e)
\r
63 MembershipUser user = Membership.GetUser (((CreateUserWizard) sender).UserName);
\r
64 roles_lst.Enabled = false;
\r
67 while (i < roles_lst.Items.Count) {
\r
68 if (roles_lst.Items[i].Selected) {
\r
70 Roles.AddUserToRole (((CreateUserWizard) sender).UserName, roles_lst.Items[i].Text);
\r
72 catch (Exception ex) {
\r
73 ((CreateUserWizard) sender).UnknownErrorMessage = ex.Message;
\r
80 public void CreateUserWizard1_CreatingUser (object sender, LoginCancelEventArgs e)
\r
82 ((CreateUserWizard) sender).DisableCreatedUser = !active_chb.Checked;
\r