review_dotnet

java中多用配置文件来对代码解耦,而依赖注入是更高级的解耦。

学习设计模式的诀窍在于掌握在何时使用这些模式。

.net / java 动态编译 使程序得以支持海量并发,不像php/asp每次被请求时都进行解释执行。

cakephp 用到2个关键技术 : ActiveRecord & Association Data Mapping

.net 2.0之后,创建aspx文件会同时创建3个类,WebForm1_aspx, 2 partial WebForm1 class. WebForm1_aspx extends WebForm1

<%@ Page Language="C#" CodeBehind="WebForm1.aspx.cs" Inherits="TestProject.WebForm1" AutoEventWireup="true"  %>
page生命周期10阶段

  1. PreInit
  2. Init
  3. InitComplete
  4. PreLoad
  5. Load
  6. LoadComplete
  7. PreRender
  8. PreRenderComplete
  9. SaveStateComplete
  10. Unload


InitComplete之前没有viewstate,textbox就不能用

Load发生在所有控件事件之前,PreRender发生在所有控件事件之后

AutoEventWireup="true" 的意思就是 自动触发9个阶段,如果方法被定义了的话,Page_InitComplete除外.
往别的页面提交的时候,获取数据有2种,一种强类型,一种弱类型。强类型是把要传的控件的值设为属性,弱类型是在接收页面里findcontrol.
windows server2003 保存文件用 NETWORK SERVICE 账号,windows xp用 ASPNET账户。

.net framework 提供3种身份验证方式 : Windows身份验证 、.NET Passport身份验证(.net passport sdk,注册还要付费)、Forms身份验证。


btn_click(object sender, ImageClickEventArgs) //只要第二个参数不是EventArgs,就表示一定有附加的事件信息传给了处理程序。


viewstate 存值: State["xxxxxx"]=0;


page CompliationMode //可以将页面搞成解释执行,不进行动态编译


AjaxValidator.


ashx // http 处理程序


httpRuntime maxRequestLength //指定提交的表单能够被服务器端接受的最大值

httpRuntime requestLengthDiskThreshold //设定上传表单到服务端内存的阀值,超出这个阀值的部分被缓存到文件系统中,即临时文件夹中


不要把大块数据都读到内存中,然后保存,应该一块一块读取,8040Byte,.WRITE,从数据库读取和往数据库里存都要一块一块来。


生成事件

public delegate void EventHandler(object sender, EventArgs e);
private EventHandler action;
public event EventHandler action{
  add{ action += value;}
  remove{ action -= value;}
}

简单点的写法就是:

public event EventHandler action;

Theme主题:

t1->多个css

t2->多个css

皮肤不建议使用


数据绑定控件

TreeView不支持模板。

Repreater,DataList,FormView需要模板,否则无法显示数据。

GridView,DetailsView,Menu支持模板,但不是必需。

<%#Eval("Date","{0:D}")%>
等价于
<%#DataBinder.Eval(Container.DataItem,"Date","{0:D}")%>
 Eval()利用反射技术根据名称查找属性,有性能损失。

<%#((System.Data.DataRowView)Container.DataItem)["Date"]%>

自然是数组的性能来的快一些。

Cookie:
会话cookie : Response.Cookies["key"].Value = value;
持久化cookie:Response.Cookies["key"].Value = value; Response.Cookies["key"].Expires = DateTime.Now.AddYears(2);
多值cookie: if(Response.Cookies["key"].HasKeys){var val = Response.Cookies["key"]["skey"]}




posted @ 2011-09-08 17:33  lein.wang  Views(147)  Comments(0Edit  收藏  举报