ÈçºÎʹÓÃASP.NET Profile
Asp.NetÖÐÓÐÒ»Ì×ÓëÓû§Ïà¹ØÁªµÄÊôÐÔÉèÖ㬿ÉÒÔͨ¹ýÔÚWebConfigÀïÅäÖÃÀ´Ö±½ÓʹÓã¬ËûµÄ×÷ÓÃΪ
´æ´¢ºÍʹÓÃΨһÓëÓû§¶ÔÓ¦µÄÐÅÏ¢
Õ¹ÏÖ¸öÈË»¯°æ±¾µÄWebÓ¦ÓóÌÐò
Óû§µÄΨһÉí·Ý±êʶÔÚÔٴηÃÎÊʱʶ±ðÓû§
Asp.Net ProfileÌṩµÄ¸úÓû§Ïà¹ØµÄÀàÐͶ¼ÊÇÇ¿ÀàÐÍ
Ê×ÏÈÉú³ÉÊý¾Ý¿â½Å±¾£¬Ê¹ÓÃVisual Studio 2005 ÃüÁîÌáʾ£¬ÊäÈëÃüÁîÐÐaspnet_regsql -A p -sqlexportonly filename
-A£º±íÃ÷Ôö¼ÓÒ»¸öÊý¾Ý¿â
p£º±íÃ÷Éú³ÉµÄÊÇProfileµÄÊý¾Ý¿â
-sqlexportonly£º±íÃ÷Êǵ¹³ösql½Å±¾£¬ÓÃÆäËû²ÎÊý¿ÉÒÔÖ±½Ó´´½¨Êý¾Ý¿â£¬¾ßÌåµÄ˵Ã÷¿ÉÒԲο´aspnet_regsqlµÄ°ïÖú˵Ã÷
filename£º±£´æµÄÎļþÃû
ÏÖÔÚÊý¾Ý¿â´´½¨ºÃÁË£¬ÀïÃæÓÐ4Õűíaspnet_ApplicationÓÃÀ´´æ´¢Ó¦ÓóÌÐòµÄÏà¹ØÀàÐÍ£¬aspnet_ProfileÓÃÀ´±£´æÓû§µÄÊôÐÔÐÅÏ¢£¬aspnet_SchemaVersionÓÃÀ´´æ´¢°æ±¾ÐÅÏ¢£¬aspnet_UserÓÃÀ´±£´æÓû§ÐÅÏ¢¡£¿ÉÒÔ´ÓÕ⼸Õűí¿ÉÒÔ¿´µ½£¬¶à¸öÓ¦ÓóÌÐò¿ÉÒÔÓÃͬһ¸öÊý¾Ý¿âÀ´±íʾÓû§ÐÅÏ¢¡£
ÏÂÃæÊÇÈçºÎÀ´ÅäÖÃWebConfigÀ´Ö§³ÖProfile
Ê×ÏÈÅäÖÃÁ¬½Ó×Ö·û´®
<connectionStrings>
<add name="ProfileDatabase" connectionString="Server=192.168.1.2; Initial Catalog=aspnetdb; User ID=sa; Password=sa"/>
</connectionStrings>
È»ºóÔÚsystem.web½ÚµãÏÂÌí¼Óprofile½Úµã
<profile enabled="true" automaticSaveEnabled="true" defaultProvider="SqlProvider">
<providers>
<clear />
<add name="SqlProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="ProfileDatabase"
applicationName="ProfileSample"
description="Sample for ASP.NET profile and Profile Service" />
</providers>
<properties>
<add name="Name" type="System.String"/>
<add name="Email" type="System.String" />
<add name="Age" type="System.Int32" />
<group name="Address">
<add name="City" type="System.String" />
<add name="Street" type="System.String" />
<add name="PostalCode" type="System.String" />
</group>
</properties>
</profile>
Ïêϸ˵Ã÷һϡ£automaticSaveEnalbed="true"£¬±íÃ÷Óû§ÔÚÌá½»Êý¾ÝÖ®ºó£¬×Ô¶¯±£´æÓû§ÊôÐÔ¡£properties½ÚµãÏÂÃæ¾ÍÊÇÓû§ÐèÒªÅäÖõÄ×Ô¼ºµÄÓû§ÊôÐÔ£¬group±íÃ÷ÕâÊÇÒ»¸ö×飬Ïàµ
Ïà¹ØÎĵµ£º
ASP.NET 2.0
Îļþ£±: Deafault.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&l ......
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["BackUrl"] = Request.UrlReferrer.ToString();
}
}
/// <summary>
/// ·µ»Ø°´Å¥µã»÷ʼþ
/// </summary& ......
“<%#....%>” ÕâÊÇÊý¾Ý°ó¶¨£¬ÀïÃæ¿ÉÒÔµ÷ÓÃC#µÄ·½·¨¡£
“<%$....%>" û¼û¹ýÕâ¸ö¡£
“<%@...%>”Õâ¸öÊÇÒ³ÃæÖ¸Áһ°ã·ÅÔÚÿ¸öÒ³ÃæµÄ×²¿£¬¶ÔÒ³ÃæµÄÔËÐнøÐпØÖÆ£¬ÈçÉèÖûº´æ£¬ÒýÓÃÓû§¿Ø¼þ£¬µ¼ÈëÃüÃû¿Õ¼ä==
ÁíÍ⻹ÓÐÒ»¸ö<%= ...%> Õâ¸ö=ºÅºóÒ²¿ÉÒÔµ÷ÓÃC#µÄ·½· ......
·¢ËͶËÒÔ163ΪÀý
Ò»¡¢asp.net°æ using System.Web.Mail; //ÃüÃû¿Õ¼äÒýÓÃ
c#
MailMessage mail = new MailMessage();
mail.To = "shadow103@qq.com"; //½ÓÊÜÈ˵ÄÓÊÏä
& ......
ÕâÊÇҪʵÏֵŦÄÜ£º
µÚÒ»²½£ºÍÏÈëGridView¿Ø¼þ ²¢ÇÒÍê³É²éѯËùÓÐÊý¾ÝµÄ·½·¨ ͨ¹ýthis.GridView1.DataSource »ñÈ¡¼¯ºÏÊý¾Ý GridView1.DataBind() °ó¶¨Êý¾Ý
µÚ¶þ²½£ºÊµÏÖÈ«Ñ¡¹¦ÄÜ
1. Ò³Ãæ´úÂ룺
´úÂë
<asp:TemplateField HeaderText="È«Ñ¡">
&nbs ......