Update user profile
web.config [Modified Parts]
<authentication mode="Windows" />
<profile>
<properties>
<add name="Name"/>
<add name="Country"/>
</properties>
</profile>
UpdateProfile.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
Profile.Name = "Jenny Jones";
Profile.Country = "Rome";
Label1.Text = "Profile data<br />";
Label1.Text += "<i>Name: " + Profile.Name;
Label1.Text += "<br />Country: " + Profile.Country+ "</i>";
}
}
protected void Button1_Click(object sender, System.EventArgs e) {
Profile.Name = TextBox1.Text.ToString();
Profile.Country = TextBox2.Text.ToString();
Label1.ForeColor = System.Drawing.Color.HotPink;
Label1.Text = "Profile data updated successfully<br />";
Label1.Text += "<i>Name: " + Profile.Name;
Label1.Text += "<br />Country: " + Profile.Country + "</i>";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to update profile in asp.net (overwrite, modify user profile data)</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">asp.net Profile example: Update Profile</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
Font-Bold="true"
ForeColor="SeaGreen"
>
</asp:Label>
<br /><br />
<asp:Label
ID="Label2"
runat="server"
Font-Bold="true"
ForeColor="Navy"
Text="Name"
>
</asp:Label>
<asp:TextBox
ID="TextBox1"
runat="server"
BackColor="Crimson"
ForeColor="Snow"
>
</asp:TextBox>
<br />
<asp:Label
ID="Label3"
runat="server"
Font-Bold="true"
ForeColor="Navy"
Text="Country"
>
</asp:Label>
<asp:TextBox
ID="TextBox2"
runat="server"
BackColor="Crimson"
ForeColor="Snow"
>
</asp:TextBox>
<br />
<asp:Button
ID="Button1"
runat="server"
Font-Bold="true"
ForeColor="SeaGreen"
Text="Update Profile"
OnClick="Button1_Click"
/>
</div>
</form>
</body>
</html>


