易截截图软件、单文件、免安装、纯绿色、仅160KB

定义和使用ASP.NET Profile(附例)

1、双击一个数据源控件,将要存储profile的数据库作为数据源加入控件(这个步骤没什么用,只是为了方便大家用控件建立连接,这样不容易出错),建立好之后将design页面的数据源控件删除,你会发现在web.config里还是有一条连接语句,不要删除,我们下面将用到它,如: <connectionStrings>
  <add name="aspnetdbConnectionString" connectionString="Data Source=JAMESSHENG;Initial Catalog=aspnetdb;Integrated Security=True" providerName="System.Data.SqlClient"/>
 </connectionStrings>
2、定义Profile,在源码中加入
  <profile enabled="true" automaticSaveEnabled="true" defaultProvider="SqlProvider">
   <providers>
    <clear/>
    <add name="sqlProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="aspnetdbConnectionString" applicationName="ProfileSample" description="Sample for asp.net Profile and Profile Service"/>
   </providers>
   <properties>
    <add name="BackGroudColor" type="System.String" allowAnonymous="true"/>
   </properties>
  </profile>
  <anonymousIdentification enabled="true"/>
//defaultprovider指定默认配置文件提供程序的名称 
   automaticSaveEnabled指定用户配置文件是否在 ASP.NET 页执行结束时自动保存。如果为true,则用户配置文件在 ASP.NET 页执行结束时自动保存。
   providers(可选元素)定义配置文件提供程序的集合,它当中包含<add> :name = defaultProvider的值;type = System.Web.Profile.SqlProfileProvider是使用sql;connectionStringName = aspnetdbConnectionString使用上面连接中定义的连接字符串;
properties(必选的元素)定义用户配置文件属性和属性组的集合,它当中包含<add>:name=“BackGroudColor”定义Profile中的属性名称;type="System.String"字符串类型;allowAnonymous="true"定义是否保存匿名用户配置,如果在此处定义true,则在后面必须加入<anonymousIdentification>配置,设


相关文档:

通过避免下列10个常见ASP.NET缺陷使网站平稳运行


ASP.NET 成功的其中一个原因在于它降低了 Web 开发人员的门槛。即便您不是计算机科学博士也可以编写 ASP.NET 代码。我在工作中遇到的许多 ASP.NET 开发人员都是自学成材的,他们在编写 C# 或 Visual Basic® 之前都在编写 Microsoft® Excel® 电子表格。现在,他们在编写 Web 应用程序,总的来说,他们所做的工 ......

ASP.NET(C#)返回上一页(后退)代码

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        ViewState["BackUrl"] = Request.UrlReferrer.ToString();
    }
}
/// <summary>
/// 返回按钮点击事件
/// </summary& ......

Asp.Net常用的三十三种代码

1. 打开新的窗口并传送参数:
  传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
  接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
  2.为按钮添加对话框
Button1 ......

如何使用ASP.NET Profile


Asp.Net中有一套与用户相关联的属性设置,可以通过在WebConfig里配置来直接使用,他的作用为
存储和使用唯一与用户对应的信息
展现个人化版本的Web应用程序
用户的唯一身份标识在再次访问时识别用户
Asp.Net Profile提供的跟用户相关的类型都是强类型
首先生成数据库脚本,使用Visual Studio 2005 命令提示,输入 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号