<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    網站開發

    asp.net
    隨筆 - 30, 文章 - 0, 評論 - 9, 引用 - 0
    數據加載中……

    置頂隨筆

    [置頂]解決downlist 等優先極高于其它控件,浮在其它控件上面

     <iframe style="position:absolute;z-index:9;width:expression(this.nextSibling.offsetWidth);height:expression(this.nextSibling.offsetHeight);top:expression(this.nextSibling.offsetTop);left:expression(this.nextSibling.offsetLeft);" frameborder="0" ></iframe>
      <div id="divTool" onmouseover="javascript:showdiv123()" onmouseout="javascript:HiddivTool()" class="class_title"  style="display:none">
    <table width="100" border="0"  align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="20" colspan="2" bgcolor="ffffff" style="width: 100px" >&nbsp;&nbsp;<span class="t1" style="cursor:hand" name="layout/AddPage.aspx" onclick="javascript:openMyPage(this)">More tools</span></td>
      </tr>
      <tr>
        <td height="20" colspan="2"  bgcolor="ffffff"  style="width: 100px">&nbsp;&nbsp;<a href="#">About this tools</a></td>
      </tr><tr>
        <td height="8" colspan="2" bgcolor="ffffff" style="width: 100px"></td>
      </tr>
     
      </table>
    </div>

    posted @ 2007-12-26 14:35 風雨兼程 閱讀(328) | 評論 (0)編輯 收藏

    [置頂]IList GetCategories();的問題

    petshop4.0中的一段代碼  
       
      public   interface   ICategory   {  
       
      ///   <summary>  
      ///   Method   to   get   all   categories  
      ///   </summary>  
                      ///   <returns>Interface   to   Model   Collection   Generic   of   categories</returns>  
                 
                     
      IList<CategoryInfo>   GetCategories();  
                     
       
                      ///   <summary>  
                      ///   Get   information   on   a   specific   category  
                      ///   </summary>  
                      ///   <param   name="categoryId">Unique   identifier   for   a   category</param>  
                      ///   <returns>Business   Entity   representing   an   category</returns>  
                      CategoryInfo   GetCategory(string   categoryId);  
      }  
       
       
      我知道IList<CategoryInfo>是范型  
      表示list中的item是CategoryInfo對象  
       
       
      請問為什么用IList<CategoryInfo>  
      用List<CategoryInfo>可以嗎?  
       
      兩者有什么區別?謝謝  

    沒有什么區別,這樣寫靈活性大,實現ilist接口的類很多,你寫成list后,也許以后你要改成非list的,就會要改很多代碼
    舉個例子  
       
      RenderControlToString(DataList   L//Control   C)  
       
      你認為是寫control還是寫datalist代碼的通用性高?

      OOP編碼原則:盡可能用接口編程

    posted @ 2007-12-26 11:44 風雨兼程 閱讀(471) | 評論 (0)編輯 收藏

    [置頂]關于sqlhelper.cs

    public abstract class SqlHelper
              {
                  public static readonly string connectionString = ConfigurationManager.ConnectionStrings["SqlConnString"].ConnectionString;
            
                  SqlConnection conn;

                  #region open SqlConnection
                  public static void Open() {
                       conn = new SqlConnection(connectionString);
                       if (conn.State != ConnectionState.Open)
                          conn.Open();
                  }    
                  #endregion

                  #region close SqlConnection
                  public static void Close() {
                      if (conn != null)
                      {
                          conn.Close();
                          conn.Dispose();
                      }
                  }        
                  #endregion

                  #region prepare SqlCommand
                  private static void PrepareCommand(SqlCommand cmd, CommandType cmdType, string cmdText, SqlParameter[] cmdParms) {
                      Open();
                      cmd.Connection = conn;
                      cmd.CommandType = cmdType;
                      cmd.CommandText = cmdText;

                      if (cmdParms != null)
                      {
                          foreach (SqlParameter parm in cmdParms)
                              cmd.Parameters.Add(parm);
                      }
                  }
                  #endregion

                  #region parm cache
                  /*
                   使用一個哈希表來保存緩存的參數 只緩存參數名
                   哈希表的特點:一個鍵對應一個值key對value(為object需要類型轉化)        不能出現兩個相同的鍵 否則error
             
                   下面的哈希表parmCache定義為static即一次定義全局使用
                   所以可能會出現有人在讀的時候,有人在寫,一般會用Lock就像Asp中用Application["count"]來統計點擊數一樣
                   要先鎖后解鎖
                   但.net框架提供了Synchroized          sync和syncroize中文意思 同步,同時發生
                   來提供這一操作
                  */
                  private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable());

                  public static void CacheParameters(string cacheKey, params SqlParameter[] commandParameters) {
                      parmCache[cacheKey] = commandParameters;
                  }

                  /*
                  1、為何要克隆呢 為何不直接return cachedParms
             
                  有一個參數數組
                  SqlParameter[] parms={
                  new SqlParameter("@num1",SqlDbType.Int,4),
                  new SqlParameter("@num2",SqlDbType.Int,4)
                  }
                  緩存該數組
                  用戶a和b都執行插入操作
                  a用戶插入了1,1
                  b用戶插入了2,2
                  如果不用克隆的話,參數數組只有一份
                  而2個用戶需要根據不同的情況賦于不同的值
                  所以就用了克隆了
            
                  2、(ICloneable)cachedParms[i]先將HashTable轉為ICloneable這樣HashTable就具有了Clone()克隆方法了
                  克隆一份后是什么類型呢,,當然要強制轉化為(SqlParameter)了
                  最后將它賦值給clonedParms[i]
                  */       
                  public static SqlParameter[] GetCachedParameters(string cacheKey) {
                      SqlParameter[] cachedParms = (SqlParameter[])parmCache[cacheKey];

                      if (cachedParms == null)
                          return null;
                      SqlParameter[] clonedParms = new SqlParameter[cachedParms.Length];

                      for (int i = 0; i < cachedParms.Length; i++)
                          clonedParms[i] = (SqlParameter)((ICloneable)cachedParms[i]).Clone();

                      return clonedParms;
                  }
                  #endregion        
            
                  //below method support sqltext and procedure

                  #region ExecuteReader
                  /*
                   parms的作用,這也是一個知識點
                   舉例:
                   ExecuteReader(*,*,null)成功運行
                   ExecuteReader(*,*,new SqlParameter(*))成功運行
                   ExecuteReader(*,*,new SqlParameter(*),new SqlParameter(*))成功運行
                   ExecuteReader(*,*,{new SqlParameter(*),new SqlParameter(*),})成功運行
                   它讓參數類型和參數個數任意
                   這可給了不是一般的好處,你不必為SqlParameter和SqlParameter[]進行重載,寫上兩個函數
                   又為null寫上一個函數,因為null會不明確調用SqlParameter的函數還是SqlParameter[]的函數
                   啥你不知道我在說什么,打屁屁,那回去看看c++的函數重載
                   */
                  public static SqlDataReader ExecuteReader(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) {
                
                      SqlCommand cmd = new SqlCommand();

                      try {
                          PrepareCommand(cmd, null, cmdType, cmdText, commandParameters);
                          SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                          cmd.Parameters.Clear();
                          return rdr;
                      }
                      catch {
                          Close();
                          throw;
                      }
                  }
                  #endregion

                  #region ExecuteNonQuery
                  public static void ExecuteNonQuery(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) {

                      SqlCommand cmd = new SqlCommand();

                      PrepareCommand(cmd, cmdType, cmdText, commandParameters);
                      cmd.ExecuteNonQuery();
                      cmd.Parameters.Clear();

                      Close();
                  }
                  #endregion

                  #region ExecuteScalar
                  public static object ExecuteScalar(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) {

                      SqlCommand cmd = new SqlCommand();

                      PrepareCommand(cmd, cmdType, cmdText, commandParameters);
                      object val = cmd.ExecuteScalar();
                      cmd.Parameters.Clear();

                      Close();
                      return val;
                  }
                  #endregion


              }
    }

    posted @ 2007-12-26 10:30 風雨兼程 閱讀(904) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 亚洲成人免费网站| 美女裸体无遮挡免费视频网站| 亚洲国产一区二区三区青草影视| 免费毛片毛片网址| 亚洲国产精品毛片av不卡在线| 91嫩草私人成人亚洲影院| 一级毛片成人免费看免费不卡| 四虎在线免费播放| 亚洲成AV人在线观看天堂无码| 一级有奶水毛片免费看| 国产又黄又爽又刺激的免费网址| 中文字幕在线观看亚洲视频| 国产一卡二卡3卡四卡免费| 亚洲av永久综合在线观看尤物| 日韩欧美一区二区三区免费观看| 亚洲国产精品无码观看久久| 9277手机在线视频观看免费| 亚洲国产精品一区二区久| 99re6在线精品免费观看| 亚洲夜夜欢A∨一区二区三区| 成人A片产无码免费视频在线观看| 又粗又大又长又爽免费视频| 亚洲av永久无码精品三区在线4| 成年性午夜免费视频网站不卡| 色吊丝免费观看网站| 亚洲日韩精品一区二区三区无码 | 亚洲av产在线精品亚洲第一站| 日本XXX黄区免费看| 自拍偷自拍亚洲精品偷一| 亚洲精品99久久久久中文字幕| 亚洲免费福利在线视频| 国产精品成人四虎免费视频| 91视频免费网站| 亚洲一区无码中文字幕乱码| 免费jlzzjlzz在线播放视频| 中文字幕无码毛片免费看| 亚洲成av人片在线看片| 亚洲第一福利网站在线观看| 久久国产免费一区二区三区 | 亚洲AV无码一区二区三区在线观看| 一个人看的免费视频www在线高清动漫|