protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { string createdUsername = CreateUserWizard1.UserName; string createdPassword = CreateUserWizard1.Password; //dynamic profile = ProfileBase.Create(createdUsername); CreateUserWizardStep step1 = (CreateUserWizardStep)CreateUserWizard1.FindControl("Step1"); DropDownList k1 = (DropDownList)step1.ContentTemplateContainer.FindControl("ddlDept"); DropDownList k2 = (DropDownList)step1.ContentTemplateContainer.FindControl("ddlRole"); TextBox k3 = (TextBox)step1.ContentTemplateContainer.FindControl("tbxName"); TextBox k4 = (TextBox)step1.ContentTemplateContainer.FindControl("UserName"); TextBox tbxTitle = (TextBox)step1.ContentTemplateContainer.FindControl("tbxTitle"); TextBox tbxEmail = (TextBox)step1.ContentTemplateContainer.FindControl("tbxEmail"); TextBox tbxHRMS = (TextBox)step1.ContentTemplateContainer.FindControl("tbxHRMS"); Roles.AddUserToRole(createdUsername, k2.Text); //profile.dept = k1.Text; //profile.role = k2.SelectedItem.Text; //profile.name = k3.Text; //profile.username = k4.Text; //profile.Save(); string encryptedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(createdPassword, "MD5"); try { Employee emp = new Employee(); if (tbxHRMS.Text != "") { emp.HRMS = tbxHRMS.Text; } emp.Name = k3.Text; emp.Title = tbxTitle.Text; emp.HRMS = tbxHRMS.Text; emp.Department = k1.Text; emp.UserName = createdUsername; emp.Password = encryptedPassword; emp.Email = tbxEmail.Text; emp.Role = k2.SelectedItem.Text; context.Employees.Add(emp); context.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { System.Diagnostics.Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } }
protected void Page_Init(object sender, EventArgs e) { CreateUserWizard createUserWizard = new CreateUserWizard(); CreateUserWizardStep createUserWizardStep = new CreateUserWizardStep(); createUserWizardStep.ContentTemplate = new Template(); createUserWizard.WizardSteps.Add(createUserWizardStep); Panel1.Controls.Add(createUserWizard); }
protected void Page_Init(object sender, EventArgs e) { CreateUserWizard createUserWizard = new CreateUserWizard(); /* Difference Starts Here */ CreateUserWizardStep createUserWizardStep = new CreateUserWizardStep(); createUserWizardStep.ContentTemplate = new Template(); createUserWizard.WizardSteps.Add(createUserWizardStep); /* End Difference */ Panel1.Controls.Add(createUserWizard); }
protected void Page_Load(object sender, EventArgs e) { CreateUserWizardStep step = (CreateUserWizardStep)RegisterUser.FindControl("step1"); if (step != null) { // bind-uva so javascript delot za da se pojavi slikata pri upload :) FileUpload uploadedPicture = (FileUpload)step.ContentTemplateContainer.FindControl("profilePicture"); uploadedPicture.Attributes["onchange"] = "UploadFile(this)"; } }
protected void RegisterUser_CreatedUser(object sender, EventArgs e) { step = (CreateUserWizardStep)RegisterUser.FindControl("step1"); if (step != null) { FileUpload uploadedPicture = (FileUpload)step.ContentTemplateContainer.FindControl("profilePicture"); if (uploadedPicture.HasFile) { Debug.WriteLine("***** FILE FIELD HAS FILE *****"); string profilePic = uploadedPicture.FileName; string[] chopped = profilePic.Split('.'); string extension = chopped.ElementAt(chopped.Count() - 1); // ja zacuvuvam original string path = Server.MapPath("~/User/ProfilePictures/" + RegisterUser.UserName + "." + extension); uploadedPicture.PostedFile.SaveAs(path); // resizing thumbs System.Drawing.Image img = System.Drawing.Image.FromFile(path); ImageFormat imgFormat = img.RawFormat; List <float> scaledSize = scaleSize(200, 200, img.Width, img.Height); Bitmap newImg = new Bitmap(img, (int)scaledSize[0], (int)scaledSize[1]); string destPath = Server.MapPath("~/User/ProfilePictures/thumbs/" + RegisterUser.UserName + "." + extension); newImg.Save(destPath, imgFormat); // resizing standard img = System.Drawing.Image.FromFile(path); imgFormat = img.RawFormat; scaledSize = scaleSize(300, 300, img.Width, img.Height); newImg = new Bitmap(img, (int)scaledSize[0], (int)scaledSize[1]); destPath = Server.MapPath("~/User/ProfilePictures/standard/" + RegisterUser.UserName + "." + extension); newImg.Save(destPath, imgFormat); // username-ovite se unique :) po difolt storeExtra(RegisterUser.UserName + "." + extension); } else { // se stava default profilePicture.png storeExtra("profilePicture.png"); } } else { Debug.WriteLine("step is null"); } }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { string createdUsername = CreateUserWizard1.UserName; string createdPassword = CreateUserWizard1.Password; //dynamic profile = ProfileBase.Create(createdUsername); CreateUserWizardStep step1 = (CreateUserWizardStep)CreateUserWizard1.FindControl("Step1"); //DropDownList k1 = (DropDownList)step1.ContentTemplateContainer.FindControl("ddlDept"); DropDownList k2 = (DropDownList)step1.ContentTemplateContainer.FindControl("ddlRole"); TextBox k3 = (TextBox)step1.ContentTemplateContainer.FindControl("tbxName"); TextBox k4 = (TextBox)step1.ContentTemplateContainer.FindControl("UserName"); TextBox tbxEmail = (TextBox)step1.ContentTemplateContainer.FindControl("tbxEmail"); Roles.AddUserToRole(createdUsername, k2.Text); // string encryptedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(createdPassword, "MD5"); //try //{ QHSEQuiz.Model.Hub hub = new QHSEQuiz.Model.Hub(); hub.Name = k3.Text; hub.UserName = createdUsername; //.Password = encryptedPassword; if (tbxEmail.Text != "") { hub.Email = tbxEmail.Text; } else { hub.Email = "N/A"; } hub.Role = k2.SelectedItem.Text; context.Hubs.Add(hub); context.SaveChanges(); //} //catch (DbEntityValidationException dbEx) //{ // foreach (var validationErrors in dbEx.EntityValidationErrors) // { // foreach (var validationError in validationErrors.ValidationErrors) // { // System.Diagnostics.Trace.TraceInformation("Property: {0} Error: {1}", // validationError.PropertyName, // validationError.ErrorMessage); // } // } //} }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { string username = CreateUserWizard1.UserName; string password = CreateUserWizard1.Password; Roles.AddUserToRole(username, "agent"); CreateUserWizardStep step1 = (CreateUserWizardStep)CreateUserWizard1.FindControl("Step1"); TextBox Email = (TextBox)step1.ContentTemplateContainer.FindControl("Email"); TextBox PhoneNumber = (TextBox)step1.ContentTemplateContainer.FindControl("PhoneNumber"); ProfileCommon profile = Profile.GetProfile(username); //get profile of the user being created and assign it to the profile profile.Email = Email.Text; profile.PhoneNumber = PhoneNumber.Text; profile.Save(); //whenever browser shows cookie, it will be authenticated. enable autologin after creating new user if (Membership.ValidateUser(username, password)) { FormsAuthentication.SetAuthCookie(username, false); Response.Redirect("~/priv/Default.aspx"); } }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { string username = CreateUserWizard1.UserName; string password = CreateUserWizard1.Password; Roles.AddUserToRole(username, "User"); CreateUserWizardStep step1 = (CreateUserWizardStep)CreateUserWizard1.FindControl("Step1"); TextBox k1 = (TextBox)step1.ContentTemplateContainer.FindControl("Phone"); TextBox k2 = (TextBox)step1.ContentTemplateContainer.FindControl("Email"); ProfileCommon profile = Profile.GetProfile(username); profile.Phone = k1.Text; profile.Email = k2.Text; profile.Save(); if (Membership.ValidateUser(username, password)) { FormsAuthentication.SetAuthCookie(username, false); Response.Redirect("~/priv/MyProperty.aspx"); } }
protected void CreateUserWizard1_CreatedUser1(object sender, EventArgs e) { CreateUserWizard createUserWizard = (CreateUserWizard)LoginView1.FindControl("CreateUserWizard1"); CreateUserWizardStep createUserStep = (CreateUserWizardStep)createUserWizard.FindControl("CreateUserWizardStep1"); CheckBox mailCheckBox = (CheckBox)createUserStep.ContentTemplateContainer.FindControl("mailCheckBox"); if (mailCheckBox.Checked) { TextBox userNameTextBox = (TextBox)createUserStep.ContentTemplateContainer.FindControl("UserName"); TextBox passwordTextBox = (TextBox)createUserStep.ContentTemplateContainer.FindControl("Password"); TextBox emailTextBox = (TextBox)createUserStep.ContentTemplateContainer.FindControl("Email"); string userName = userNameTextBox.Text; string password = passwordTextBox.Text; string email = emailTextBox.Text; string path = Server.MapPath("~/App_Data/SignUpConfirmation.txt"); string body = File.ReadAllText(path); body = body.Replace("<%UserName%>", userName); body = body.Replace("<%Password%>", password); string toEmail = email; string SMTPUser = "******", SMTPPassword = "******"; MailMessage mail = new MailMessage(); mail.From = new MailAddress(SMTPUser); mail.To.Add(toEmail); mail.Subject = "AlgoAkademi Üyeliğiniz Hakkında"; mail.Body = body; mail.Priority = MailPriority.Normal; SmtpClient client = new SmtpClient(); client.Host = "smtp.gmail.com"; client.Port = 587; client.Credentials = new System.Net.NetworkCredential(SMTPUser, SMTPPassword); client.EnableSsl = true; client.Send(mail); } }
public static CreateUserWizard CreateTestControl(Page p) { LiteralControl lcb = new LiteralControl(HtmlDiff.BEGIN_TAG); LiteralControl lce = new LiteralControl(HtmlDiff.END_TAG); CreateUserWizard w = new CreateUserWizard(); w.ID = "CreateUserWizard1"; CreateUserWizardStep step1 = new CreateUserWizardStep(); CompleteWizardStep step2 = new CompleteWizardStep(); w.MembershipProvider = "FakeProvider"; w.WizardSteps.Add(step1); w.WizardSteps.Add(step2); p.Form.Controls.Add(lcb); p.Form.Controls.Add(w); p.Form.Controls.Add(lce); //p.ClientScript.RegisterForEventValidation (w.ID); return(w); }
public ConfigurationPage() { HtmlGenericControl style1 = new HtmlGenericControl(); style1.TagName = @"style"; style1.Attributes["type"] = @"text/css"; style1.InnerText = @"body, input, .style1 { font-family:Tahoma; font-size:9pt; }"; Header.Controls.Add(style1); //MultiView1 MultiView1 = new MultiView(); MultiView1.ActiveViewIndex = 0; //view1 view1 = new View(); //_tbl HtmlTable _tbl = new HtmlTable(); _tbl.Attributes["border"] = @"1"; //_row HtmlTableRow _row = new HtmlTableRow(); //_cell HtmlTableCell _cell = new HtmlTableCell(); _cell.Attributes["colspan"] = @"2"; _cell.Attributes["style"] = @"height: 39px"; //_literal Literal _literal = new Literal(); _literal.Text = @" تنظیمات امنیتی وب سایت: "; _cell.Controls.Add(_literal); _row.Controls.Add(_cell); _tbl.Controls.Add(_row); //_row _row = new HtmlTableRow(); //_cell _cell = new HtmlTableCell(); _cell.Attributes["style"] = @"width: 235px"; //_literal _literal = new Literal(); _literal.Text = @" محل ذخیره سازی اطلاعات کاربران: "; _cell.Controls.Add(_literal); _row.Controls.Add(_cell); //_cell _cell = new HtmlTableCell(); //uxProviders uxProviders = new RadioButtonList(); uxProviders.RepeatDirection = System.Web.UI.WebControls.RepeatDirection.Horizontal; uxProviders.Width = new Unit("385px"); uxProviders.AutoPostBack = true; uxProviders.CssClass = @"style1"; uxProviders.SelectedIndexChanged += new System.EventHandler(uxProviders_SelectedIndexChanged); //_item ListItem _item = new ListItem(); _item.Selected = true; _item.Value = @"sql"; _item.Text = @"Sql Server Database"; uxProviders.Items.Add(_item); //_item _item = new ListItem(); _item.Value = @"access"; _item.Text = @"MS Access Database"; uxProviders.Items.Add(_item); _cell.Controls.Add(uxProviders); _row.Controls.Add(_cell); _tbl.Controls.Add(_row); //trSql trSql = new HtmlTableRow(); //_cell _cell = new HtmlTableCell(); //_literal _literal = new Literal(); _literal.Text = @" رشته اتصال: "; _cell.Controls.Add(_literal); trSql.Controls.Add(_cell); //_cell _cell = new HtmlTableCell(); _cell.Attributes["dir"] = @"ltr"; //uxConnectionStrings uxConnectionStrings = new RadioButtonList(); uxConnectionStrings.CssClass = @"style1"; uxConnectionStrings.Font.Size = new FontUnit("9pt"); _cell.Controls.Add(uxConnectionStrings); trSql.Controls.Add(_cell); _tbl.Controls.Add(trSql); //trAccess trAccess = new HtmlTableRow(); trAccess.Visible = false; //_cell _cell = new HtmlTableCell(); //_literal _literal = new Literal(); _literal.Text = @" مسیر فایل Access: "; _cell.Controls.Add(_literal); trAccess.Controls.Add(_cell); //_cell _cell = new HtmlTableCell(); _cell.Attributes["dir"] = @"ltr"; //uxAccessFileName uxAccessFileName = new TextBox(); uxAccessFileName.Text = @"~/App_Data/ASPNetDB.mdb"; uxAccessFileName.Width = new Unit("190px"); _cell.Controls.Add(uxAccessFileName); trAccess.Controls.Add(_cell); _tbl.Controls.Add(trAccess); //_row _row = new HtmlTableRow(); //_cell _cell = new HtmlTableCell(); _cell.Attributes["align"] = @"left"; _cell.Attributes["style"] = @"height: 49px"; //uxOK uxOK = new Button(); uxOK.Text = @"انجام تنظیمات"; uxOK.Click += new System.EventHandler(uxOK_Click); _cell.Controls.Add(uxOK); _row.Controls.Add(_cell); _tbl.Controls.Add(_row); view1.Controls.Add(_tbl); MultiView1.Views.Add(view1); //_ctl1 View view2 = new View(); lbl = new Label(); view2.Controls.Add(lbl); //_literal _literal = new Literal(); _literal.Text = @"<br/>مشخصات کاربر Admin:"; view2.Controls.Add(_literal); //uxCreateUser uxCreateUser = new Web.Controls.CreateUserWizard(); uxCreateUser.HeaderText = @" "; uxCreateUser.UserName = "******"; uxCreateUser.CreatedUser += new System.EventHandler(uxCreateUser_CreatedUser); //_ctl3 CreateUserWizardStep _ctl3 = new CreateUserWizardStep(); _ctl3.Title = @""; uxCreateUser.WizardSteps.Add(_ctl3); view2.Controls.Add(uxCreateUser); MultiView1.Views.Add(view2); View view3 = new View(); _literal = new Literal(); _literal.Text = "کاربر Admin با موفقیت ایجاد شد."; view3.Controls.Add(_literal); MultiView1.Views.Add(view3); Form.Controls.Add(MultiView1); //uxBack uxBack = new Button(); uxBack.Text = @"بازگشت"; uxBack.Width = new Unit("60px"); uxBack.Click += new System.EventHandler(uxBack_Click); Form.Controls.Add(uxBack); }
public void CreateUserWizardStep_StepType_Set() { CreateUserWizardStep step = new CreateUserWizardStep(); step.StepType = WizardStepType.Start; }
public void CreateUserWizardStep_StepType_Get() { CreateUserWizardStep step = new CreateUserWizardStep(); Assert.AreEqual(WizardStepType.Auto, step.StepType, "CreateUserWizardStep_StepType_Get"); }