RSS 2.0 Feed
2004-07 Entries
摘要:下载 http://www.lostinet.com/files/WinXPThemeRoyal.zip 出处在哪里,已经不记得了。...[阅读全文]

posted @ | Feedback (15) | Filed Under [ 迷失中 ]

摘要:请到 http://www.lostinet.com/files/XsltArgs.rar 下载例子源代码。 这个例子首先读取xml和xslt:XmlDocument xmldoc=new XmlDocument();xmldoc.Load(Server.MapPath(ResolveUrl("XmlFile1.xml")));XslTransform xt=new XslTransform();xt.Load(Server.MapPath(ResolveUrl("XsltFile1.xslt"))); 然后创建XsltArgumentList:XsltArgumentList arglist=new XsltArgumentList(); 并且以XML名字空间"uri:myservice"的名义。把MyService的实例放到XsltArgumentList中:arglist.AddExtensionObject("uri:myservice",new MyService()); 最后进行转换:xt.Transform(xmldoc,arglist,Response.Output,null); 这个代码很简单。关键是在Xslt里怎样用这个"uri:myservice" 首先在 stylesheet 里定义 xmlns:app="uri:myservice"<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:app="uri:myservice">这样,就可以在表达式里直接应用uri:myservice了。 <xsl:value-of select="app:GetDateTimeString()" />这里调用的是MyService.GetDateTimeString() <xsl:value-of select="app:Add(@a,@b)" />这里调用的是MyService.Add(int a,int b) 当然,除了常规的数据类型。你还可以传递XPathNodeIterator进去。这个与 xmlns:msxsl="urn:schemas-microsoft-com:xslt" 是一致的。 不过优点与缺点,主要就是编译期间的问题了。(做这个是因为一个朋友说msxsl代码编译时找不到他写的类库,目前我不太清楚怎样控制xslt里的编译行为)如果代码比较临时,并且可能根据不同的xslt来写不同的代码,那么推荐使用msxsl来写。如果你本身有一些写好的东西了,或者不想同样的东西到处写,或者xslt根本就不是你负责的,就可以使用XsltArgumentList了。 关于msxsl请参考Saucer的文章:在.NET里用XSLT时怎么使用msxsl:script(http://blog.joycode.com/saucer/archive/2004/05/12/21273.aspx) 更新一:<xsl:value-of select="app:Add(app:Sum(add/@a),app:Sum(add/@b))" />...[阅读全文]

posted @ | Feedback (1) | Filed Under [ DotNet AspNet ]

摘要:谁来解析一下这个做法:(Asp.Net1.0/1.1/2.0) <% @ Page Inherits="LostinetWebsite.Aspx" %>  ...[阅读全文]

posted @ | Feedback (9) | Filed Under [ DotNet AspNet ]

摘要:上星期没有花时间学习。这个星期也只学了一天: 新的资源绑定语法 <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学习 ]

摘要:http://www.cnblogs.com/huobazi/archive/2004/07/10/22926.aspx 我这里也有一个类似的解决方案: <script> window._open=window.open; window.open=window_new_open; function window_new_open( a,b,c ) { var win; if( c ) win=window._open( a,b,c ); else if( b ) win=window._open( a,b ); else win=window._open( a ); if( win!=null&&!win.closed ) return win; var option='status:0;help:0;dialogleft:10000px;dialogtop:10000px;dialogheight:0px;dialogwidth:0px'; win=showModalDialog( 'open.htm',[a,b,c],option ); return win; } </script> <script> var win=window.open( 'http://www.lostinet.com/' ); win.close( ); </script> 其中 open.htm 为:<title>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</title> <script> function window.onload( ) { var args=window.dialogArguments; var a=args[0]; var b=args[1]; var c=args[2] var win; if( c ) win=window.open( a,b,c ); else if( b ) win=window.open( a,b ); else win=window.open( a ); window.returnValue=win; window.close( ); } </script> 这个的好处就是不用改变已有的代码。只要想办法把这个代码放进原来的网页的前面把window.open替换掉就可以了。...[阅读全文]

posted @ | Feedback (73) | Filed Under [ Browser ]

摘要:以前写了很多个重写了Equals的类, 通常我比较它们,都是先看看类型是否符合,然后再看成员的意义是否一致。 例如public override bool Equals(object obj){ ClassA a=obj as ClassA; if(a==null)  return false;  return this._x==a._x&&this._y==a._y;} 这个Equals往往用在一些容器里,例如ArrayList.IndexOf之类的。它们使用object.Equals(object obj1,object obj2)来判断对象是否相等 在这些方法的使用上,大多数情况都是直接查询该对象都是引用相同的。 也就是说,上面代码的比较实在太慢了。 那是不是应该加上 if(obj==(object)this) 呢? 我想应该不太需要。 因为在 object.Equals(obj1,obj2) 里,第一步是直接判断引用是否相同的。 我也觉得像 mya.Equals( b ) 这样直接调用Equals方法的情况不多。 (当然上面说的对于ValueType也是有效的。因为装了箱的Value的方法能直接被调用。) 关于重载 == 和 != ,ValueType和RefType的处理方法是不同的。 ValueType如果不重载==/!=操作符号,是不能使用这些符号的。而RefType则默认用“引用相等”来判断两对象是否相同。 对于RefType我个人意见就是尽量使用object.Equals(obja,objb)来完成, 而对于ValueType,我则喜欢用重载了的Equals 下面给出了一个实例代码:using System; namespace ConsoleApplication1 { class ClassA { public int _x; public int _y; public override int GetHashCode() { return (_x+":"+_y).GetHashCode(); } public override bool Equals(object obj) { ClassA a=obj as ClassA; if(a==null) return false; return this._x==a._x&&this._y==a._y; } public override string ToString() { return _x+":"+_y; } static public bool operator == (ClassA x,ClassA y) { return object.Equals(x,y); } static public bool operator != (ClassA x,ClassA y) { return !object.Equals(x,y); } //如果下面的不提供,那么编译器会给出警告 static public bool operator == (ClassA x,object y) { return object.Equals(x,y); } static public bool operator != (ClassA x,object y) { return !object.Equals(x,y); } static public bool operator == (object x,ClassA y) { return object.Equals(x,y); } static public bool operator != (object x,ClassA y) { return !object.Equals(x,y); } } struct ValueA { public int _x; public int _y; public......[阅读全文]

posted @ | Feedback (2) | Filed Under [ DotNet ]

摘要:对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学习 ]