web.config里面的
<configuration>
<system.web>
<authentication mode="Forms"/>
<anonymousIdentification enabled="true"/>
<profile>
<properties>
<add name="FirstName" defaultValue="null" allowAnonymous="true"/>
<add name="LastName" defaultValue="null" allowAnonymous="true"/>
<add name="PageVisits" type="Int32" allowAnonymous="true"/>
</properties>
</profile>
<compilation debug="true"/>
</system.web>
</configuration>aspx页面里的代码
<%@ Page Language="C#" %>
<script runat="server"> void Page_Load() {
this.Profile.PageVisits++;
}
void UpdateProfile(Object s, EventArgs e) {
this.Profile.FirstName = this.txtFirstName.Text;
this.Profile.LastName = this.txtLastName.Text;
}
</script><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Profile</title>
</head>
<body>
<form id="form1" runat="server">
Name: <%= this.Profile.FirstName %> <%= this.Profile.LastName %><br />
Page Visits:<%= this.Profile.PageVisits%>
First Name:<asp:TextBox ID="txtFirstName" Runat="Server" /><br />
Last Name:<asp:TextBox ID="txtLastName" Runat="Server" /><br />
<asp:Button ID="Button1" Text="Update Profile" OnClick="UpdateProfile" Runat="server" />
</form>
</body>
一运行就提示无法连接到SQL server数据库。是网上找的。。那段代码需要连接数据库呢?~应该要怎样弄哦。。谢谢……
<configuration>
<system.web>
<authentication mode="Forms"/>
<anonymousIdentification enabled="true"/>
<profile>
<properties>
<add name="FirstName" defaultValue="null" allowAnonymous="true"/>
<add name="LastName" defaultValue="null" allowAnonymous="true"/>
<add name="PageVisits" type="Int32" allowAnonymous="true"/>
</properties>
</profile>
<compilation debug="true"/>
</system.web>
</configuration>aspx页面里的代码
<%@ Page Language="C#" %>
<script runat="server"> void Page_Load() {
this.Profile.PageVisits++;
}
void UpdateProfile(Object s, EventArgs e) {
this.Profile.FirstName = this.txtFirstName.Text;
this.Profile.LastName = this.txtLastName.Text;
}
</script><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Profile</title>
</head>
<body>
<form id="form1" runat="server">
Name: <%= this.Profile.FirstName %> <%= this.Profile.LastName %><br />
Page Visits:<%= this.Profile.PageVisits%>
First Name:<asp:TextBox ID="txtFirstName" Runat="Server" /><br />
Last Name:<asp:TextBox ID="txtLastName" Runat="Server" /><br />
<asp:Button ID="Button1" Text="Update Profile" OnClick="UpdateProfile" Runat="server" />
</form>
</body>
一运行就提示无法连接到SQL server数据库。是网上找的。。那段代码需要连接数据库呢?~应该要怎样弄哦。。谢谢……
public virtual int PageVisits {
get {
return ((int)(this.GetPropertyValue("PageVisits")));
}
set {
this.SetPropertyValue("PageVisits", value);
}
}这个get访问器中