<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
Profile.Name = "Jenny Jones";
Profile.Save();
}
}
protected void Button1_Click(object sender, System.EventArgs e) {
Label1.Text = "Profile data read...<br /><br />";
Label1.Text += "<i>Name: " + Profile.Name;
Label1.Text += "<br />Member: " + Profile.Member + "</i>";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to set profile default value in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Red">asp.net Profile example: Profile Default Value</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
Font-Bold="true"
ForeColor="SteelBlue"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
Font-Bold="true"
ForeColor="SteelBlue"
Text="Show Profile"
OnClick="Button1_Click"
/>
</div>
</form>
</body>
</html>
web.config [Modified Parts]
<authentication mode="Windows" />
<profile>
<properties>
<add name="Name"/>
<add name="Member" defaultValue="No"/>
</properties>
</profile>
No comments:
Post a Comment