惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
SecWiki News
SecWiki News
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
量子位
M
MIT News - Artificial intelligence
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
H
Heimdal Security Blog
腾讯CDC
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threatpost
月光博客
月光博客
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
T
Troy Hunt's Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
D
DataBreaches.Net
O
OpenAI News
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
小众软件
小众软件
V
Vulnerabilities – Threatpost
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
美团技术团队
P
Privacy International News Feed

博客园 - RevengeBoy

请求帮助 SQL 2005 master..xp_cmdshell 死锁问题 Rc4 encrypt in PeopleSoft - RevengeBoy CSS隐藏滚动条 - RevengeBoy - 博客园 程序员 2008的最后一天 大家有什么感想说出来吧 vista ie7 window.confirm() 取消按钮 失效 解决办法 - RevengeBoy 魔兽争霸III 1.20, 1.21 1.22 需要特定语言版本之Window 解决办法 css 换行 且不分割最后一个单词 - RevengeBoy 英文系统 中 中文成了乱码问题 sql 查询第5行到第7行 之间的行 反射技术与工厂方法 (using C#) 图片水印效果 - RevengeBoy - 博客园 Membership、MembershipUser和Roles类 上传大文件控件 显示进度条! (OnClientClick 和 OnClick 新页面回传值)(gridview中获取控件 获取值) [转]ASP.NET(C#)常用代码33例 电脑常识---[二] 最近创作---用户控件 蓦然回首 dropdownlist 下的 SelectedValue 问题
profile 的使用(更换皮肤转换语言)
RevengeBoy · 2007-07-12 · via 博客园 - RevengeBoy

纯粹个人笔记,不代表任何技术发表

安装数据库:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe

数据库起名为:MembershipDB

config 配置:

<configuration>
 <appSettings/>
 <connectionStrings>
    <add name="GSEGC_ConnectionString" connectionString="Data Source=localhost;Initial Catalog=MembershipDB;Integrated Security = true" providerName="System.Data.SqlClient" />
 </connectionStrings>
 <system.web>
    <membership>
      <providers>
        <remove name="AspNetSqlMembershipProvider" />
        <add connectionStringName="GSEGC_ConnectionString" enablePasswordRetrieval="false"
     enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/"
     requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5"
     minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1"
     passwordAttemptWindow="10" passwordStrengthRegularExpression=""
     name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </providers>
    </membership>
    <roleManager enabled="true">
      <providers>
        <remove name="AspNetSqlRoleProvider" />
        <add connectionStringName="GSEGC_ConnectionString" applicationName="/"
     name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </providers>
    </roleManager>
    <profile defaultProvider="SqlProvider">
      <providers>
        <clear />
        <add name="SqlProvider"
      type="System.Web.Profile.SqlProfileProvider"
      connectionStringName="GSEGC_ConnectionString"
      applicationName="/"
      description="SqlProfileProvider for SampleApplication" />
      </providers>
      <properties>
        <add name="MyTheme" defaultValue="msn_cherryblossom"></add>      //定义MyTheme
        <add name="MyLanguage"  defaultValue="zh-cn"/>                                 //定义MyLanguage
      </properties>
    </profile>

.cs  下
using System.Threading;
using System.Globalization;

   protected void  Page_PreInit()// 获得皮肤事件
    {
        //if (Request.Form != null && Request.Form.Count > 0)
        //   this.Theme = this.Request.Form["DropDownList1"].Trim();

        // set the theme for the page. post-data is not currently loaded
        // use trace="true" to see the form collection
        ProfileCommon pc = new ProfileCommon();//匿名用户配置文件
        ProfileCommon pc2 = pc.GetProfile(Page.User.Identity.Name);//得到当前用户的配置文件
        this.Theme = pc2.MyTheme;
   }

    protected override void InitializeCulture() //转换语言事件
    {
        ProfileCommon pc = new ProfileCommon();//匿名用户配置文件
        ProfileCommon pc2 = pc.GetProfile(Page.User.Identity.Name);//得到当前用户的配置文件
        string UserCulture = pc2.MyLanguage;
        if (UserCulture != "")
        {
            //根据Session的值重新绑定语言代码
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(UserCulture);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(UserCulture);
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        try
        {
            ProfileCommon pc = new ProfileCommon();//匿名用户配置文件
            ProfileCommon pc2 = pc.GetProfile(Page.User.Identity.Name);//得到当前用户的配置文件
            string UserCulture = pc2.MyLanguage;
            if (UserCulture.ToUpper() == "EN-US")
            {
                pc2.MyLanguage = "zh-cn";
                pc2.Save();
            }
            else if (UserCulture.ToUpper() == "ZH-CN")
            {
                pc2.MyLanguage = "en-us";
                pc2.Save();
            }
            //重定向页面
            Response.Redirect(Request.Url.PathAndQuery);
        }
        catch (Exception)
        {
            throw;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        this.Button2.Text = Resources.Language.BtnOkText;
    }