RSS 2.0 Feed
2005-08 Entries
摘要:ASP.NET之父Scott Guthrie,最近在他的blog上登出了一连串有关ASP.NET 2.0和VS 2005的文章, 1。VS 2005中的Web项目系统提供的新功能 (VS 2005 Web Project System: What is it and why did we do it?) 2。如何在VS 2005和Web项目系统中使用 IIS (Using IIS with VS 2005 and the new Web Project system) 3。如何设置 ASP.NET 2.0的应用服务使用SQL Server 2000和SQL Server 2005 (Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005) 4。更好地管理VS 2005Web项目中文件的几个技巧 (Some techniques for better managing files in VS 2005 Web Projects) 5。如何使用VS 2005建立可重用的ASP.NET用户控件和页面库 (Building Re-Usable ASP.NET User Control and Page Libraries with VS 2005)...[阅读全文]

posted @ | Feedback (4) | Filed Under [ ASP.NET/IIS ]

摘要:(兼回答CSDN论坛的一个问题) 因为Session是在HttpApplication的AcquireRequestState事件后才有的,而Page类(或其他HttpHandler)的对象是在此之前生成的,看一下HttpApplication的事件次序 BeginRequestAuthenticateRequestAuthorizeRequestResolveRequestCache----Page类(或其他HttpHandler)的对象在此生成AcquireRequestStatePreRequestHandlerExecute----Page类(或其他HttpHandler)的对象的ProcessRequestPostRequestHandlerExecuteReleaseRequestStateUpdateRequestCacheEndRequest 如果你想深入了解ASP.NET处理请求过程,参考Rick Strahl的文章 A low-level Look at the ASP.NET Architecture...[阅读全文]

posted @ | Feedback (1) | Filed Under [ ASP.NET/IIS ]

摘要: 最近经一个同事介绍,在读《Head First Design Patterns》这本书,感觉其风格很是有趣,本来想写篇介绍的,但Google了一下,发现这位老兄的介绍非常全面,那我就偷懒了吧。 这本书里的编码用的是 Java,Mark McFadden 把它们转换成了C# [来源:Darrell Norton [MVP]]。 在用Google查询时,发现Sahil Malik [MVP C#] 用 A** first design pattern 为题在贬Oracle的高级.NET Web Service 例子,甚是好笑,  。回复中有个连接,更是好玩,叫 The Daily WTF,上面登的都是有问题或风格很差的编码,可以跟 Web Pages That Suck 媲美了...[阅读全文]

posted @ | Feedback (9) | Filed Under [ 书籍 ]

摘要:[来源:Mike Stall] ...超过4千3百万行编码,超过30个开发组,700个开发人员,每天要生成100种不同的build... "...When we ship an official release like a Beta or RTM (release to market) we lock down and are code complete several months before the actual release date to allow for a final test pass, to stabilize and hit stress goals, then get the best bits to fulfillment for mass production of media..." 这么说的话,估计现在已经是 code complete 了 详见Mike Stall的blog或MSDN的反馈页...[阅读全文]

posted @ | Feedback (7) | Filed Under [ 杂类 ]

摘要:对于 6。 整数交换 Java:         int x = 1984;        int y = 2001;        x ^= y ^= x ^= y;        System.out.println("x = " + x + "; y = " + y); C#:        int x = 1984;        int y = 2001;        x ^= y ^= x ^= y;        System.Console.WriteLine("x = " + x + "; y = " + y); 输出结果一样 Java x = 0; y = 1984 C# x = 0; y = 1984 fancyf 在上个post的回复中建议这个是Bug,其实不然,因为根据Specifications, x ^= y ^= x ^= y; 其运算是这么做的(起码当前版本是如此): "...The order in which operands in an expression are evaluated, is left to right. [Example: For example, in F(i) + G(i++) * H(i), method F is called using......[阅读全文]

posted @ | Feedback (8) | Filed Under [ 书籍 .NET ]

摘要:Joshua Bloch 是Java语言组的设计师,去年离开Sun加盟Google,他的《Effective Java》一书在Java界影响很大。最近与Google的同事Neal Gafter (也是前Sun雇员) 合写了《Java Puzzlers: Traps, Pitfalls, and Corner Cases》。该书的几个条目以及全部Source Code可以在www.javapuzzlers.com下载到 我不想介入Java与C#间的比较,但还是不禁想比较一下里面的例子在C#里的行为。 下面是第二章里的几个例子的比较,是在.NET 2.0.50215 和Java 1.5.0下做的,至于结果为什么不一样,建议参考2门语言的Specifications。 1。奇偶性  Java:     public static boolean isOdd(int i) {        return i % 2 == 1;    } C#:    public static bool isOdd(int i) {        return i % 2 == 1;    } 输出结果是一样的,这里涉及负整数的余数的问题,但输出结果也许跟你想的也许不一样 isOdd i=-2 i=-1 i=0 i=1 i=2 Java false false false true false C# False False False True False 2。浮点数的减法 Java: System.out.println(2.00 - 1.10); C#: System.Console.WriteLine(2.00 - 1.10); 输出结果不一样 Java 0.8999999999999999 C# 0.9 对C#这个结果有点怀疑,大概是格式化的原因,因为如果用ILDASM看的话,是这样的   IL_0000:  ldc.r8     0.89999999999999991  IL_0009:  call       void [mscorlib]System.Console::WriteLine(float64) 3。大整数除法 Java:        final long MICROS_PER_DAY = 24 * 60 * 60 * 1000 * 1000;        final long MILLIS_PER_DAY = 24 * 60 * 60 * 1000;         System.out.println(MICROS_PER_DAY / MILLIS_PER_DAY); C#:        const long MICROS_PER_DAY = 24 * 60 * 60 * 1000 * 1000;        const long MILLIS_PER_DAY =......[阅读全文]

posted @ | Feedback (3) | Filed Under [ 书籍 .NET ]

摘要:看到同站博客linkcd很有趣的问题,虽有点直感,但因对CLR研究不深,所以Google了一下,看到了CLR开发组项目经理Joel Pobar的blog《CLR Type System notes》。他从Reflection的角度对ReferenceType,ValueType,Primitive (Scalar types),Enum,Array,ByRef,TypedRef,(unmanaged) Pointer,COMObject,Interface,TransparentProxy,Delegate等类型做了分析。跟问题有关的是其中的byref类型,对此,他是这么说的 ".... ByRef ByRef types are managed pointers. ByRef don't box and there are very few IL instruction that can be performed on ByRef types (i.e. ldind.ref, stind.ref). Because of that restriction there is never an instance of a ByRef type as far as reflection is concerned. However ByRef types are real, concrete types in the type system. Inspecting a method that takes a ByRef arg will reveal a unique type that is in no relationship with the type it represents (i.e. int& and int are in no relationship). Reflection simulates ByRef and it's the user......[阅读全文]

posted @ | Feedback (4) | Filed Under [ 拾慧 .NET ]

摘要:如何设置STAThread...[阅读全文]

posted @ | Feedback (0) | Filed Under [ .NET ]

摘要:这个问题反复在论坛出现,其实这个问题在MSDN上早就有答案1。英文版:Top Questions about the DataGrid Web Server Control(Mike Pope and Nikhil Kothari)2。中文版:DataGrid Web 伺服器控制项的常见问题 可惜,论坛上的风气不太好,你即使给了连接,真正去看的人大概并不多 诀窍是,如果动态添加了列的话,需要在下一次PostBack时,在LoadViewState或更早把这些列重新添加。原因是,在Page类递归调用LoadViewState时,会调用DataGrid的CreateChildControls,而DataGrid的(实际上是它的父类的实现)CreateChildControls会调用DataGrid的CreateControlHierarchy()方法。在其中,DataGrid会根据当前的列的数目构造DataGridItem里的东西,然后从ViewState里恢复原来的数据。如果你没有重新添加你的动态列的话,你的动态列在PostBack后就会消失,更不用谈触发列里的控件的事件了 检验你的动态控件在PostBack后是否还在的一个方法是,加一个按钮看PostBack后的行为 下面是一个简单的测试 <html><body><form runat="server"><asp:DataGrid id="DataGrid1" runat="server" GridLines="Both" AutoGenerateColumns="false"OnItemCommand="DataGrid1_ItemCommand"> <Columns> <asp:ButtonColumn HeaderText="Static Button" Text="Click Me"  CommandName="Static"/> <asp:TemplateColumn HeaderText="Data">  <ItemTemplate><%#Container.DataItem%></ItemTemplate> </asp:TemplateColumn> </Columns></asp:DataGrid><asp:Button id="btnAddAColumn" runat="server" Text="Add a column" OnClick="AddButtonColumn"/><asp:Button id="btnRefresh" runat="server" Text="Refresh" /></form></body></html><script language="C#" runat="server">void BindGrid(){ DataGrid1.DataSource = new string[] {"a","b","c"}; DataGrid1.DataBind();} void Page_Load(object sender, EventArgs e){  if (!IsPostBack)  { BindGrid();  }} void DataGrid1_ItemCommand(Object sender, DataGridCommandEventArgs e){ Response.Write("ItemCommand is called<BR>"); LinkButton btn = e.CommandSource as LinkButton; if (btn != null)  Response.Write(String.Format("{0} is clicked on row {1}", btn.CommandName, e.Item.ItemIndex));         } //lifted from the original postpublic void CreateGridColumn(DataGrid OperationDataGrid){   ButtonColumn NewButCol = new ButtonColumn() ;   NewButCol.Text = "编辑" ;   NewButCol.HeaderText = "操作" ;   NewButCol.CommandName = "Edit" ;   NewButCol.ButtonType = ButtonColumnType.LinkButton;  ......[阅读全文]

posted @ | Feedback (7) | Filed Under [ ASP.NET/IIS ]