技巧

序加载顺序:Code->Page
页面任何地方都可以用<%=*****%>的形式来使用绑定的数据,包括js脚本里面

-------------------------------------------------------------------------------------------------
函数空间:System.Collections.ArrayList
下拉框某项加颜色:this.Select1.Items[1].Attributes.Add("style","COLOR:green");

使用using关键字自动清除对象资源。会自动调用MyObject的Dispose方法,
替代try{}catch{}finally{ MyObject.Dispose ( ) ; }
-------------------------------------------------------------------------------------------------
HashTable的键值对:http://blog.csdn.net/hunterxray/archive/2007/03/30/1546415.aspx
   System.Collections.Hashtable htKey=new System.Collections.Hashtable();
   htKey.Add("htb","hval");
取值一: 
  System.Collections.SortedList sLst=new SortedList();
   sLst.Add("mykey","myVal");
   foreach(object o in sLst.Keys)
   {
    Response.Write("Key="+Convert.ToString(o)+"<br>value="+sLst[o]);
   }
取值二:
      foreach (DictionaryEntry myDE in SQLStringList)
    { 
       string name=Convert.ToString(myDE.Key);
       string val=Convert.ToString(myDE.Value);
    }

  SortedList 是 Hashtable 和 Array 的混合。由于要进行排序,所以在 SortedList 上操作比在 Hashtable 上操作要慢。但是,SortedList 允许通过相关联键或通过索引对值进行访问,可提供更大的灵活性。
http://blog.csdn.net/lostowner/archive/2006/03/17/627435.aspx
-------------------------------------------------------------------------------------------------
TextBoxMaxLength可以设置输入文本的长度了

GridView等显示数据超过加三点 Page里面实现
<%#Convert.ToString(DataBinder.Eval(Container.DataItem,"ic_title")).Trim().Length>20?Convert.ToString(DataBinder.Eval(Container.DataItem,"ic_title")).Trim().Substring(0,20)+"...":Convert.ToString(DataBinder.Eval(Container.DataItem,"ic_title")).Trim()%>
-------------------------------------------------------------------------------------------------
DataTimeObj.ToString("M月d日 H:mm") //日期格式
-------------------------------------------------------------------------------------------------

    public override void VerifyRenderingInServerForm(Control control)
    {
        //重载该方法解决,控件必须在runat=server的问题
    }

-------------------------------------------------------------------------------------------------

posted @ 2007-07-09 17:51  Microbar  阅读(217)  评论(0编辑  收藏  举报