RSS 2.0 Feed
DotNet2学习
摘要: 把VS.NET2005Beta2下载了下来,一直都没有好好地去研究一下。今天突然想到一个有意思的Idea,关于程序中数据的获取方式的。反正想试试而已,于是顺便练习了一下范型。通常做数据缓存的时候,都是依靠Cache来实现的。其实DotNet的垃圾回收和WeakReference类就可以用来做缓存了。测试的代码如下://5 using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; namespace Test1 { #region 第一部分,通用的 public interface IDataItemProvider<K, T> { void GetItem(SomeContext context, K key, out T val); } public class SomeContext { public SomeContext(SqlConnection conn) { if (conn == null) throw (new ArgumentNullException("conn")); ......[阅读全文]

posted @ | Feedback (8) | Filed Under [ 迷失中 DotNet DotNet2学习 ]

摘要:上星期没有花时间学习。这个星期也只学了一天: 新的资源绑定语法 <asp:Button ID=Button1 Text='<%$ Resources:test1, Button1Text, "HelloWorld" %>' OnClick="Button1_Click" runat=server />这是 Asp.Net 的多语言方案了。<%$ Resources:test1, Button1Text, "HelloWorld" %> 的意思是从 Resources 或 Code 中得到 test1 这个 resx 中的 Button1Text 的字符串, 而 "HelloWrod" 则作为设计时的资源。我在 Resources/test1.resx 内添加了 Button1Text ,值是 "你好!" 然后就显示出来了:) <%$ Code:"HelloWorld" %>->Parser Error Message: The expression prefix 'Code' was not recognized. Please correct the prefix or register the prefix in the <expressionBuilders> section of configuration. <expressionBuilders> 在 <compilation> 下 <compilation debug="true"> <expressionBuilders>  <add expressionPrefix="MyExp" type="MyExpBuidler"/> </expressionBuilders></compilation> <asp:Button ID=Button2 Text='<%$ MyExp : HelloWorld %>' OnClick="Button1_Click" runat=server /> using System;using System.CodeDom;using System.Collections;using System.Web;using System.Web.Compilation; public class MyExpBuilder : System.Web.Compilation.ExpressionBuilder{    public override System.CodeDom.CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, object parsedData, System.Web.Compilation.ExpressionBuilderContext context)    {        return new System.CodeDom.CodePrimitiveExpression("["+entry.Expression+"]");    }}得到 <input......[阅读全文]

posted @ | Feedback (5) | Filed Under [ DotNet AspNet DotNet2学习 ]

摘要:对DotNet2.0的新的特征,我还是个菜鸟。写点笔记,希望对您也有帮助. 特殊文件夹是 bin,code,data ..引用一个dll是把这个dll复制到bin中引用GAC的东西是在web.config里配置compilation的assembliesconfig文件是有schema的.<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">可以新建MDF文件(注意,不是MDB),这个文件可以在DataExplorer里用(Using the filename:)来关联打开Code文件夹下的代码文件会在运行时自动编译。Resource1.resx会自动生成一个读取资源的类Resource1,资源可以直接用Resource1.String1的方式来读global:: 关键字。例如 global::System.Text 防止名字空间的冲突在DatabaseExplorer的连接字符串中, servername 为 .\SqlExpress , Using the filename 用 K:\Websites\DljPortal\Data\db.mdfxx.master 里的标记是 <%@ Master Language="C#" %><font face="宋体"></font>变成<span style="font-family: 宋体">sdffds</span>了。。。。右键点master文件,有"Add Content Page"。。生成<%@ Page Language="C#" MasterPageFile="~/Portal.master" Title="Untitled Page"%>Page有默认的Title属性了。。(这个可以用来传递到Master中。)在有Master的Aspx中,右键点某个Content,出现"Create Custom Content"或"Default To Master's Content"可以在Ashx里写代码了。 如果装了SqlServer Express,那么在VWD会自动为Data/下的MDF文件在Database Explorer中创建管理的连接的。 Visual C# Express 支持多个Project。可以把jpg等资源文件直接拖进resx的设计视图中web.config中的httpHandlers下的type可以是CODE文件夹下的类同一个CODE目录下如果resx文件名字重复,则会发生冲突.这个在类视图中也会自动分开显示 system.web/compilation/codeSubDirectories/add 允许指定代码目录。如果指定的目录不存在,则报告错误这个指定的目录相对CODE,例如directoryName="MyCode" 则代表 CODE/MyCode这个目录指定后,里面的东西会分开来编译。。这样可以防止资源冲突,也可以用来防止类名冲突。修改了一个文件作成的影响也会小点。VWD认得这个设置,并且把目录的颜色变成灰蓝的。 VWD Web Server 处理 /aa.aspx/bb.jpg 的方法与 IIS 不同 VWD 支持编译 Web 工程。可以用来检查CODE下的代码。目前不清楚还能干什么的。 VWD Web Server 的端口比较固定?。连续几次都是32773 把jpg拖到资源文件中,然后在提出来,结果变成BMP了。然后Save到Jpeg中时发现大了很多。 aspnet_compiler 是一个把asp.net的程序进行编译的工具 开始 PersonalWebsite 例子学习 要看vs2005的文章可以到http://lab.msdn.microsoft.com/vs2005/articles/default.aspx [SQL BROWSER] 这个服务用于列出机器以及周围的SQL实例。 Web.config 中使用 <system.web>        <pages stylesheettheme="White">            <controls>                <add tagPrefix="uc1" tagName="Frame" src="Controls/Frame.ascx" />            </controls>        </pages>就可以使各页面不用再编写<%@ Register %>了。这个还可以随时更换呢。(不知道可不可以使用web.config的目录规则而在不同的目录下做不同的配置以达到Skin的效果?)如果一个控件在这里注册后,那么直接把这个控件拖进另外的设计视图时,<%@ Register %>是不会生成的。 控件的skinid 与 Themes/???/Default.skin 是对应的。在Default.skin里可以修改用skinid指定的控件的属性!例如<asp:image runat="server" Imageurl="Images/button-create.gif" style="border:1px;" htmlexpando1="myvalue" skinid="create" /> (这个style还是自动合并的!)默认使用的Theme名字是在<pages stylesheettheme="White">里指定的。 asp:loginview提供了AnonymousTemplate和LoggedInTemplate。 Persenal Startkit 的Login好象有问题,登陆时说Your login attempt was not successful. Please try again.不过它提供CommandName="Submit",这个难道是用于Bubble到<asp:login>中的。。(不错的做法。让元素成为自己的一个部分,用Command来定义这个元素的意义)<asp:login>里面提供的LayoutTemplate根据元素的id的约定来获取必要的信息。。UserName/Password/RememberMe/FailureText   周末是属于家人的,所以无法学习了。...[阅读全文]

posted @ | Feedback (5) | Filed Under [ DotNet AspNet DotNet2学习 ]

摘要:要定义,一个Generic的类,应该要定义一个相关的接口,就像 Nullable 一样。 public class Nullable : ...., INullableValue 今天做了一个类,突然想这样 if( obj is Nullable< ? > ) ,其实我就是想知道这个对象是否为某种Nullable < T >,而不必要具体到某个具体的类中。我不想用反射,而if(obj is Nullable< object >) 是错的。 到了这个时候,我才发现INullableValue的作用。因为我也没有限定一定要是Nullalbe。 最后 if(obj is INullableValue) 就OK了。。 不过希望DotNet能提供这个if( obj is GenericType<?> )的功能。。 ...[阅读全文]

posted @ | Feedback (1) | Filed Under [ DotNet Browser DotNet2学习 ]

摘要:刚刚试了一下 Visual C# Express 。发现新建工程的时候并没有提示放在哪里。。觉得怪怪的。 后来新建文件,测试,最后完成了。等我关闭它的时候,问我是否保存它?按道理当然保存啦。 这才发现它现在才问我保存在哪里~~~~~! 原来现在VC#支持像VB6那样的,新建工程,工作,然后不保存就退出。这样就不用在硬盘上留下什么东西了。 这用来测试真的比以前方便多了。 不过如果你是真的要做东西,我觉得还是先把工程保存了,然后再做的好。不然万一停电了。。。...[阅读全文]

posted @ | Feedback (11) | Filed Under [ DotNet DotNet2学习 ]

摘要:VWD 提供一个内置的 Web Server ,使我们可以不依赖 IIS 就能直接进行开发。 它在处理 /handler.ashx/pathinfo.jpg 这样的 url 上则与 IIS 有差别。 这个差别是 IIS 会把这个作为 /handler.ashx 来处理,而在 VWDWS 中会作为 pathinfo.jpg 来处理。 这个问题部署后就不再有,但是在开发时却很麻烦。 要解决这个问题,可以用HttpContext.RewritePath来替换路径。如果在Global.Asax中做,就是: void Application_BeginRequest(object sender, EventArgs e) { string srcfilepath = Context.Request.FilePath; string srcfplower=srcfilepath.ToLower(); int pos1 = srcfplower.IndexOf(".aspx"); if(pos1==-1) pos1 = srcfplower.IndexOf(".ashx"); ......[阅读全文]

posted @ | Feedback (2) | Filed Under [ DotNet AspNet DotNet2学习 ]

摘要:aspnet_compiler 是一个把整个网站进行编译的工具。 C:\WINNT\Microsoft.NET\Framework\v2.0.40607>aspnet_compiler -? Utility to precompile an ASP.NET application Copyright ( c ) Microsoft Corporation 2001-2003. All rights reserved. Usage: aspnet_compiler [-?] [-m metabasePath | -v virtualPath [-p physicalDir]] [targetDir] -? Prints this help text. -m The full IIS metabase path of the application. This switch cannot be combined with the -v or -p switches. -v ......[阅读全文]

posted @ | Feedback (10) | Filed Under [ DotNet AspNet DotNet2学习 ]