小新的技术天地

Make It Works !

博客园 首页 新随笔 联系 订阅 管理
  131 Posts :: 1 Stories :: 489 Comments :: 11 Trackbacks

2008年4月4日 #

刚才在CNBETA看到的消息,微软将不再提供VB6.0 IDE的技术支持,想当年大学二级还是用VB6.0考的呢,呵呵,还是很不错的开发工具跟语言。

当然现在是.NET的时代,目前发布版本已经到了.NET3.5,很多新功能没用过,呵呵,应该好好学习一下了。
posted @ 2008-04-04 09:59 小新0574 阅读(663) | 评论 (1)编辑

2007年12月12日 #

大家好,好久没有更新博客了,工作挺多的,而且休息的时候现在更愿意花时间去外面跟朋友面对面聊天,所以不常更新博客了。
回想去年7月从大学毕业到现在,也有一年半了,毕业后来到上海,这个纷繁的城市,生活节奏一下子快了起来,觉得每天都有很多事情,工作日不说,反而是双休日显得更忙。
工作上,毕业以后,通过上海的Tony同学的帮助,得以顺利在上海开始职业生涯。到现在,做过了三个不同的职位,刚开始做开发,后来做开发测试,再到上个月才开始的Test Leader,从不同的职位角度观察的软件的整个开发流程,当然鉴于工作资历,了解得还不是很深入。待遇方面也算是翻了一番多点,算是给了自己一些继续向上的信心跟动力。也就是在上个月,面对持续上涨的房价压力,在家人的帮助下,买了房子,明年就开始还房贷的生涯,也算是给自己又多了一份压力。不过家人在首付上给了很大的帮助,所以还贷压力不算是很大,明年打算存点钱,学习学习理财,毕竟上海算是金融城市,大家都在谈论理财方面的问题,所以整体学习氛围还是挺好的。
一切都是变化的那么快,自己的脚步完全不能停,还有好长的路要走,明年的计划还没想好,现在还在适应新的工作,新的职位,在语言上觉得英语已经没有太大障碍,只要持续关注跟使用,应该会越来越好,其他方面,想学一些方言,现在想到的是上海话跟粤语,前者对我难度较小,毕竟都是江南的语系,后者就要看有没有朋友跟我练习了,呵呵。
写在最后,提一下,英语确实是很有用的一门技能,不但是职业成长上对你有帮助,在交际上也很有帮助,通过英语在上海认识了很多国家的朋友,跟他们聊一些风土人情,还有对各种问题的看法,会得到有趣的观点跟观念,不但让我感到新奇,更让我受益匪浅。
posted @ 2007-12-12 12:15 小新0574 阅读(357) | 评论 (2)编辑

2007年7月25日 #

Silverlight1.0马上就要发布了,为了尽快抢占Flash占有的网络多媒体市场吧,随着视频共享应用的火热,潜藏了太大的广告商机,当然还有在线休闲小游戏什么的,甚至广告本身就可以用Silverlight做。
如果Silverlight1.0跟Flash很像的话(效果比较相似,后台都用解释性的AS跟JS),那么Silverlight1.1的野心就更大一点,为了构建下一代的网络应用程序(not website, but web application). 由于miniCLR的介入,原来的.NET平台语言将得到支持,更由于新的DLR的增加,新的动态语言也将获得支持,当然还有最吸引眼球的LINQ了,也包含入SL的framework里了,这是目前版本的.NET3.0还没有的,可见MS对LINQ的重视。
posted @ 2007-07-25 23:25 小新0574 阅读(420) | 评论 (1)编辑

2007年1月21日 #

好久不写技术文章了,虽然每天也在关注技术,不过也一直在学英语。在知道电脑这东东以前,英语一直是我在学习上最喜欢的科目,从英语上我了解到的并不只是一种语言工具,更是让我了解到另一种文化,另一个世界的思考方式。工作以后,工作环境需要英语技能,虽然谈不上刻意去学,至少是每天在用。最近几个月更是对口语的兴趣很大,可以跟外籍的经理交流,也在生活中认识一些外籍朋友,同时也感觉到上海确实是中国数一数二的国际化城市,在很多社交场合,英语已经作为一种重要的交流工具。在职业生涯的发展中,就如一个外籍朋友所言,英语很重要。
学习英语,环境比较重要,有些时候,你花了很多时间去背单词,还不如跟外籍的一些朋友做一次简单的交谈,在交流中,你会发现你实实在在在使用这门语言,而不是背了很多单词等着去忘记。
posted @ 2007-01-21 17:05 小新0574 阅读(443) | 评论 (5)编辑

2006年9月30日 #

     摘要: Part1请参见:http://www.cnblogs.com/wdxinren/archive/2006/09/30/518952.html1. VIEWSTATE STORES VALUESIf you've ever used a hashtable, then you've got it. There's no rocket science here. ViewState has an i... 阅读全文
posted @ 2006-09-30 15:26 小新0574 阅读(3640) | 评论 (10)编辑

原文:http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx
翻译:小新0574

前几天看到
思归同学推荐了几篇好文章,看了一篇确实觉得不错,。但是贴个链接,又是英文的,看的人就不会很多,我就翻译给大家吧。不过最近挺懒的,导致前一篇想翻译的文章 夭折,所以这次就分几次翻译好了.不过原文没有分成几部分,英文好的同学自己可以去看,不用等我哈。

TRULY Understanding ViewState

ViewState is a very misunderstood animal. I would like to help put an end to the madness by attempting to explain exactly how the ViewState mechanism works, from beginning to end, and from many different use cases, such as declared controls vs. dynamic controls.

ViewState是一只非常容易让人误解的动物。我想结束为了尝试解释清楚ViewState的工作机制而搞得一团糟的状况,从头到尾,从各种不同的用例,比如说declared controls vs. dynamic controls(术语我都不翻了哈)

There are a lot of great articles out there that try to dispel the myths about ViewState. You might say this is like beating a dead horse (where ViewState is the horse, and the internet is the assailant). But this horse isn't dead, let me tell you. No, he's very much alive and he's stampeding through your living room. We need to beat him down once again. Don't worry, no horses were harmed during the authoring of this article.

已经有许多很好好的文章尝试驱散ViewState的神秘。你可能会认为这就像打一只死马(这里ViewState是那只马,internet是打的人)但让我来告诉你,这只马并不是死的。其实它十分活泼,在你的卧室惊跑(这作者还真能掰的)我们需要再一次把它击倒。别担心,写这篇文章的时候没有马会受伤.

It's not that there's no good information out there about ViewState, it's just all of them seem to be lacking something, and that is contributing to the community's overall confusion about ViewState. For example, one of the key features that is important to understand about ViewState is how it tracks dirtiness. Yet, here is a very good, in-depth article on ViewState that doesn't even mention it! Then there's this W3Schools article on ViewState that seems to indicate that posted form values are maintained via ViewState, but that's not true. (Don't believe me? Disable ViewState on that textbox in their example and run it again). And it's the #1 Google Search Result for "ASP.NET ViewState". Here is ASP.NET Documentation on MSDN that describes how Controls maintain state across postbacks. The documentation isn't wrong per say, but it makes a statement that isn't entirely correct:

"If a control uses ViewState for property data instead of a private field, that property automatically will be persisted across round trips to the client."

其实并不是外界没有关于ViewState的好的资料,只是他们都缺少了一些东西,而造成整个社区对于ViewState的迷惑。比如说,其中一个关键特性就是,理解ViewState怎么tracks dirtiness很重要的。然后,这里有一片很好的,深入的关于ViewState的文章似乎指出posted form values使用viewstate维护,但这是不正确的。(不相信我?Disable他们那个例子上的textboxViewState,再运行一次)。这是关于"ASP.NET ViewState"#1 Google Search Result。这里是ASP.NET Documentation on MSDN,解释了Controls怎么across postbacks维护ViewState.这个文档每一句话都没错,当时他得出的一个statement并不完全正确:

如果一个控件为属性值使用ViewState来代替私有字段,这个属性会往返于客户端时自动被持久化

That seems to imply that anything you shove into the ViewState StateBag will be round-tripped in the client's browser. NOT TRUE! So it's really no wonder there is so much confusion on ViewState. There is no where I've found on the internet that has a 100% complete and accurate explanation of how it works! The best article I have ever found is this one by Scott Mitchell. That one should be required reading. However, it does not explain the relationship of controls and their child controls when it comes to initialization and ViewState Tracking, and it is this point alone that causes a bulk of the mishandlings of ViewState, at least in the experiences I've had.

这好像暗示说,任何你扔给ViewState StateBag的东西,都会往返于客户浏览器。这不是真的!这么看来,对ViewState有这么对困惑真的一点都不奇怪了。我在internet真找不出能100%完全正确解释Viewstate是怎么工作的文章。我曾今找到最好的一片是this one by Scott Mitchell。这篇值得阅读。然而,这文章并没有解释控件和他们子控件在初始化和ViewState Tracking时的关系,而这正是造成大量误用ViewState的关键所在,至少在我的经验中是这样的。

So the point of this article will be to first give a complete understanding of how ViewState basically functions, from beginning to end, hopefully filling in the holes that many other articles have. After a complete explanation of the entire ViewState process, I will go into some examples of how developers typically misuse ViewState, usually without even realizing it, and how to fix it. I should also preface this with the fact that I wrote this article with ASP.NET 1.x in mind. However, there are very few differences in the ViewState mechanism in ASP.NET 2.0. For one, ControlState is a new type of ViewState in ASP.NET 2.0, but it treated exactly like ViewState, so we can safely ignore it for the purposes of this article.

所以这篇文章的首先会给出一个关于ViewState基本功能的一个完整理解,从头到尾,希望能够堵上很多其他文章的漏洞。在对整个ViewState过程的完全解释以后,我会展示一些开发人员怎么误用ViewState的例子,通常他们根本不会意识到它,和也不知道如何修复它。我首先声明我这篇文章写得一些情况是对于ASP.NET 1.X而言的。然而,ASP.NET 2.0对于ViewState机制只有极少的更改。其中一点,ControlStateASP.NET 2.0 中是一种ViewState的新类型,但是它跟ViewState几乎是一样的处理方式,所以我们可以很安全的忽略它。

First let me explain why I think understanding ViewState to it's core is so important:

首先让我解释为什么理解ViewState的核心是很重要的:

MISUNDERSTANDING OF VIEWSTATE WILL LEAD TO...

  1. Leaking sensitive data
  2. ViewState Attacks - aka the Jedi Mind Trick -- *waves hand* that plasma tv is for sale for $1.00
  3. Poor performance - even to the point of NO PERFORMANCE
  4. Poor scalability - how many users can you handle if each is posting 50k of data every request?
  5. Overall poor design
  6. Headache, nausea, dizziness, and irreversible frilling of the eyebrows.

 错误理解ViewState会造成

  1. 丢失敏感数据
  2. ViewSate攻击 - aka the Jedi Mind Trick -- *waves hand* that plasma tv is for sale for $1.00
  3. 糟糕的性能甚至可以到达没有性能的程度
  4. 糟糕的可伸缩性 如果每一次请求都post 50K的数据有多少用户可以处理
  5. 糟糕的全局设计
  6. 头痛,反胃,头昏眼花,皱眉头(这作者真是

 

If you develop an ASP.NET Application and you don't take ViewState seriously, this could happen to you:

如果你开发ASP.NET程序而不严肃处理ViewState,这就会发生在你身上:
ViewStateMadness.jpg

The ViewState form data

borgcube.jpg

ViewState will add your web app's distinctiveness to it's own. Performance is futile

I could go on but that is the gist of it. Now lets move on by starting back from the beginning:

 

我可以继续,不过这些是它的要点。现在让我们从头开始:

WHAT DOES VIEWSTATE DO?
This is a list of ViewState's main jobs. Each of these jobs serves a very distinct purpose. Next we'll learn exactly how it fulfills those jobs.

  1. Stores values per control by key name, like a Hashtable
  2. Tracks changes to a ViewState value's initial state
  3. Serializes and Deserializes saved data into a hidden form field on the client
  4. Automatically restores ViewState data on postbacks

 

ViewState做了什么?

这里是ViewState所作的主要工作的一个列表。每一个工作都达到了一个不同的目的。接下来我们会了解到它怎么完成这些工作的。

  1. 通过键名,每一个控件保存一些值,就像Hashtable.
  2. 跟踪对ViewState初始状态的改变。
  3. 序列化和反序列化保存的数据到客户端一个隐藏字段里。(大家比较清楚的只有这点吧?)
  4. postbacks时自动恢复ViewState数据。

While ViewState does have one overall purpose in the ASP.NET Framework, it's four main roles in the page lifecycle are quite distinct from each other. Logically, we can separate them and try to understand them individually. It is often the mishmash of information on ViewState that confuses people. Hopefully this breaks it down into more bite size nuggets. Mmmm... ViewState Nuggets.

由于ViewState全面参与了ASP.NET Framework,在页面生命周期中它的四个角色各不相同。逻辑上,我们可以分割他们,尝试单独一个一个理解他们。ViewState中混乱的信息经常使人们迷惑。希望它能被打碎成小到可以被咬的nuggets…ViewState Nuggets(这作者又来这招了)


ViewStateNuggets.jpg

To be continued…

Part2
http://www.cnblogs.com/wdxinren/archive/2006/09/30/519325.html

posted @ 2006-09-30 09:53 小新0574 阅读(6714) | 评论 (14)编辑

2006年9月28日 #

不错的文章

Using the ASP.NET 2.0 ReportViewer in Local Mode
http://www.codeproject.com/aspnet/ReportViewer.asp

翻译到了一半,不想翻了,就贴个链接,英文还可以的,兴趣的朋友可以看看。
posted @ 2006-09-28 15:03 小新0574 阅读(1985) | 评论 (1)编辑

2006年9月7日 #

需求:我们的ASP.NET站点需要提供多语言支持,考虑到我们使用的是ASP.NET2.0,我们可以利用资源文件来实现。

 

NOTE:这里我们使用编程的方法实现,使用其他方法,请参见:

http://msdn2.microsoft.com/en-us/library/c6zyy3s9.aspx

 

接下来我们演示一个简单的例子

Steps:

 

Step1:Visual Studio2005中创建一个ASP.NET站点

Step2:在网站项目中添加App_GlobalResources

Note:这里我们使用全局资源文件作为演示,本地资源文件操作步骤类似,关于全局资源文件与本地资源文件的异同,请参见

http://msdn2.microsoft.com/en-us/library/ms227427.aspx

Choosing Between Global and Local Resource Files这一段

Step3:App_GlobalResources中添加项,选择Resource File模板,取名为Site.resx

Note:这是我们的默认语言资源文件,必须要有

在这个资源文件的键/值配对中写入:

Name : btnSubmitText

Value: Submit

 

Step4:增加我们需要的各种语言的资源文件,这里我们增加两个文件

Site.zh-CN.resx

在这个资源文件的键/值配对中写入:

Name : btnSubmitText

Value: 确定

Site.en-US.resx

在这个资源文件的键/值配对中写入:

Name : btnSubmitText

Value: Submit

 

Note:这里给资源文件取名的时候,需要按照如下格式:

[Class]. [Culture Name].resx

比如说Site.zh-CN.resx

关于Culture Name请参见MSDNCultureInfo类中的Remarks部分

 

Step5:在我们的Default页面中添加一个Button控件,IDbtnSubmit

Step6:在我们的Default页面中添加两个Button控件,IDbtnChinese,btnEnglish,Text为中文,English

btnChineseClick事件方法中,添加代码:

        Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN");
        btnSubmit.Text 
= Resources.Site.btnSubmitText;

btnEnglishClick事件方法中,添加代码:

        Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
        btnSubmit.Text 
= Resources.Site.btnSubmitText;

Note:如果我们不在代码里指定当前线程的CurrentUICulture,那么程序就会根据浏览器中的设置进行判断,你可以在IE中的语言设置中进行默认设置。

 

OK, 我们可以运行了。

UAT就让大家来做吧,呵呵。不出所料,一切都如我们所预料的运行。

 

 

By the way, 最近发的几篇文章难度都不是很高,其实重要的是告诉大家一种可以选择的方法,或是大家都不是很注意的一些知识点, 引导大家如果有需要继续去发掘,MSDN里有的内容,我就简要介绍或者直接给出链接,那样就不会显得文章庞大臃肿,让大家集中注意力在某一些点上。Enjoy it J

 

PS:欢迎大家加我的MSN或者QQ讨论.NET 2.0(主要是C#2.0ASP.NET2.0).NET3.0,发现我加入的几个QQ群都还挺少有人讨论这两个版本的内容的。还有一些朋友问我的很多问题,其实通过查找MSDN都可以找到答案跟示例,所以我的建议是,首先通过自己查找资料寻找解决方案。还有一些朋友直接向我要源码,或者说让我做一个MSDN示例里已经有代码的演示Project,那我的建议是,你还是自己先去尝试着做吧,我做好给你,你再看肯定没有你自己做一边效果来的好。

posted @ 2006-09-07 16:36 小新0574 阅读(2317) | 评论 (6)编辑

2006年9月4日 #

     摘要: 觉得很多人在写关于ASP.NET2.0的东东,很少有人写关于ADO.NET2.0的新特性。查找了一下MSDN,给大家介绍几点好了。(如果需要察看所有ADO.NET2.0的新特性,请查看http://msdn2.microsoft.com/en-us/library/ex6y04yf.aspx)Server Enumeration用来枚举活动状态的SQL Server实例,版本需要在SQL2000及... 阅读全文
posted @ 2006-09-04 13:13 小新0574 阅读(2377) | 评论 (0)编辑

2006年8月31日 #

初学MemberShip,遇到一个Membership设置的问题

因为一般教程使用的示例都是SQL Server 2005 Express版本的本地 ASPNETDB.MDF文件,如果我要使用远程的Sql Server 2005服务器的话,需要进行一些设置。

Setp1:当你使用Membership, 我们可以发现ASP.NET 2.0 已经在 SQL Server 2005 Express建立了很多表(aspnet_Membership),视图,存储过程等。当时我们自己的远程服务器上并没有这些表。难道我们需要自己建?当然不用,微软给我们准备了一个工具:

%systemroot%\Microsoft.NET\Framework\v2.x\

目录下的aspnet_regsql工具

根据它的向导,可以很方便地指定你的服务器和数据库。完成之后,我们可以发现,我们的远程服务器上制定数据库上已经创建好了我们需要的表,视图,存储过程等。

Step2:这时候我们需要在web.config更改MembershipProvider

我们可以参考machine.config文件中的内容:

machine.config%systemroot%\Microsoft.NET\Framework\v2.x\CONFIG目录下)

  <connectionStrings>
    
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
  
</connectionStrings>

    
<membership>
      
<providers>
        
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
      
</providers>
    
</membership>


你可以直接在machine.config里更改,不过这里一更改,会影响到以后所有ASP.NET程序的设置,所以我们还是在自己的web.config中更改比较好

web.config中,首先创建我们自己的连接字符串:

    <connectionStrings>
        
<add name="remoteSqlServer" connectionString="server=..;uid=..;pwd=..;initial catalog=.." providerName="System.Data.SqlClient" />
    
</connectionStrings>

然后修改Membershipprovider.,修改的时候需要注意一个问题,因为machine.config中已经存在一个provider了,所以你直接增加一个provider的话

        <membership>            
            
<providers>
            
            
<add name="RemoteSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="remoteSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />            
            
</providers>
        
</membership>

在程序运行中还是会去寻找在machineconfig中定义的AspNetSqlMembershipProvider,因为那个是default。所以一种选择是,我们把这个新的Provider设置为Default的。

        <membership defaultProvider="RemoteSqlMembershipProvider">
            
            
<providers>
            
            
<add name="RemoteSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="remoteSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
            
            
</providers>


另一种选择是,我们首先clear原来的provider,然后再增加自己的provider(connectiongStringName设置为我们自己的ConnectionString):

        <membership>            
            
<providers>
            
<clear/>
            
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="remoteSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />            
            
</providers>
        
</membership>

这里需要注意的另一个问题就是,provider的名字一定需要是AspNetSqlMembershipProvider,其他名字就会出现这个错误:
Default Membership Provider could not be found.
因为原来已经指定了AspNetSqlMembershipProvider为Default Provider.

PS:此文只针对SQL Server数据库

posted @ 2006-08-31 10:50 小新0574 阅读(5637) | 评论 (10)编辑