-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyProfile.aspx.cs
executable file
·73 lines (66 loc) · 2.2 KB
/
MyProfile.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Web.Security;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
public partial class MyProfile_aspx : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FirstNameTextBox.Text = Server.HtmlDecode(Profile.FirstName);
LastNameTextBox.Text = Server.HtmlDecode(Profile.LastName);
EmailTextBox.Text = Membership.GetUser().Email;
}
}
protected void SaveButton_Click(object sender, EventArgs e)
{
EmailNotValid.Visible = false;
Page.Validate("ChangeProfile");
if (Page.IsValid)
{
Profile.FirstName = Server.HtmlEncode(FirstNameTextBox.Text);
Profile.LastName = Server.HtmlEncode(LastNameTextBox.Text);
MembershipUser u = Membership.GetUser();
u.Email = Server.HtmlEncode(EmailTextBox.Text);
try
{
Membership.UpdateUser(u);
BackToMyAds();
}
catch (Exception ex)
{
EmailNotValid.Text = "This Email is in use or not allowed.";
EmailNotValid.Visible = true;
}
}
}
protected void CancelButton_Click(object sender, EventArgs e)
{
BackToMyAds();
}
protected void BackToMyAds()
{
Response.Redirect("~/MyAds.aspx");
}
protected void ChangePasswordControl_ChangedPassword(object sender, EventArgs e)
{
Page.SetFocus(ChangePasswordControl);
}
protected void FirstNameValidator_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = false;
if (Regex.IsMatch(FirstNameTextBox.Text, @"^[0-9\-\p{L}\p{Zs}\p{Lu}\p{Ll}\']{1,40}$"))
{
args.IsValid = true;
}
}
protected void LastNameValidator_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = false;
if (Regex.IsMatch(LastNameTextBox.Text, @"^[0-9\-\p{L}\p{Zs}\p{Lu}\p{Ll}\']{1,40}$"))
{
args.IsValid = true;
}
}
}