<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      繼我的Ajax服務端框架完成后, 也花了些時間學習了一Asp.net MVC,感覺我的Ajax框架也能玩MVC開發, 于是乎,在又加了點功能后,現在也能像Asp.net MVC那樣寫aspx和ascx了。

      先來點代碼來看看,具體的頁面呈現效果請參考通用數據訪問層及Ajax服務端框架的綜合示例,展示與下載

      <%@ Page Title="商品管理" Language="C#" MasterPageFile="~/MasterPage.master" 
           Inherits="FishWebLib.Mvc.MyPageView<ProductsPageData, ProductsModelLoader>" %>
      
      <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
          <script type="text/javascript" src="/js/MyPage/Products.js"></script>
      </asp:Content>
      <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
      
      <table cellpadding="4" border="0">
      <tr><td>當前分類</td><td>
              <select id="ddlCurrentCategory" onchange="<%= UiHelper.DropDownListAutoRedir("ddlCurrentCategory")%>"  
                  combobox="not-editable" style="width:300px;">
      <%= Model.Categories.ToHtmlOptions("categoryId", false, "searchWord", "page")%>
      </select>
          </td><td>
              <a id="btnCreateItem" href="#" class="easyui-linkbutton" iconCls="icon-add">添加商品</a>
          </td></tr>
      </table>
      <div style="height: 10px"></div>
      
      
      <table class="GridView" cellspacing="0" cellpadding="4" border="0" style="border-collapse:collapse;">
          <tr align="left">
              <th style="width:20px;">&nbsp;</th>
              <th style="width:550px;">商品名稱</th>
              <th style="width:120px;">單位</th>
              <th style="width:120px;">單價</th>
              <th style="width:50px;">數量</th>
          </tr>
      <% foreach( Product product in Model.Products ) { %>
          <tr>
              <td><a href="/AjaxProduct.Delete.cs?id=<%= product.ProductID %>&returnUrl=<%= this.CurrentRequestRawUrl %>" 
                      title="刪除" class="easyui-linkbutton" plain="true">
                  <img src="/Images/delete.gif" alt="刪除" /></a>
              </td>
              <td style="white-space:nowrap;">
                  <a href="#" rowId="<%= product.ProductID %>" class="easyui-linkbutton" plain="true" iconCls="icon-open" >
                      <%= product.ProductName.HtmlEncode()%></a>
              </td><td>
                  <span name="Unit"><%= product.Unit.HtmlEncode() %></span>
              </td><td>
                  <span name="UnitPrice"><%= product.UnitPrice.ToText() %></span>
              </td><td>
                  <input type="text" pid="<%= product.ProductID %>" value="<%= product.Quantity %>" class="quantityTextbox" />
              </td>
          </tr>
      <% } %>
      
      <%= Model.PagingInfo.PaginationBar(5)%>
      </table>
      
      <input type="hidden" id="hfCurrentCategoryId" value="<%= Model.CurrentCategoryId %>" />
      
      
      <div id="divProductInfo" title="商品" style="padding: 8px; display: none">
      <%= FishWebLib.Ajax.UcExecutor.Execute("~/Controls/ProductInfo.ascx", Model.ProductInfoViewData)%>
      </div>
      
      </asp:Content>
      
      
      

      再來個ascx

      <%@ Control Language="C#" Inherits="FishWebLib.Mvc.MyUserControlView<OrderListViewData>" %>
      
      <table class="GridView" cellspacing="0" cellpadding="4" border="0" style="border-collapse:collapse; width: 99%">
          <tr align="left">
              <th style="width:100px;">訂單編號</th>
              <th style="width:160px;">時間</th>
              <th style="width:300px;">客戶</th>
              <th style="width:100px;">訂單金額</th>
              <th style="width:60px;">已處理</th>
          </tr>
      <% foreach( var item in Model.List ) { %>
      <tr>
          <td>
              <a href="#" OrderNo="<%= item.OrderID %>" class="easyui-linkbutton" plain="true" iconCls="icon-open">
              <%= item.OrderNo %></a>
          </td>
          <td><%= string.Format("{0:yyyy-MM-dd HH:mm:ss}", item.OrderDate) %></td>
          <td>
              <a href="#" Customer='<%= item.ValidCustomerId %>' class="easyui-linkbutton" plain="true" iconCls="icon-open">
              <%= item.CustomerName.HtmlEncode() %></a>
          </td>
          <td><%= item.SumMoney.ToText() %></td>
          <td>
              <%= item.Finished.ToCheckBox(null, "chk_Finished", true) %>
          </td>
      </tr>
      <% } %>
      
      <%= Model.PagingInfo.PaginationBar(5) %>
      </table>
      
      
      

      與Asp.net MVC的aspx,ascx一樣:沒有與之對應的CodeFile

      再來看看"商品管理"頁面加載數據的C#代碼吧。注意類型的名稱與方法的簽名,它們在上面Page指令中有引用。

      public class ProductsModelLoader
      {
          public static ProductsPageData LoadModel()
          {
              ProductsPageData result = new ProductsPageData();
              result = new ProductsPageData();
              result.Categories = BllFactory.GetCategoryBLL().GetList();
      
              if( result.Categories.Count == 0 ) {
                  //HttpContext.Current.Response.Redirect("/Categories.aspx", true);    // 不建議使用這個方法,不利于測試
                  FishWebLib.HttpContextHelper.RequireRedirect("/Categories.aspx");
                  return null;
              }
      
              // 獲取當前用戶選擇的商品分類ID
              result.CurrentCategoryId = FishWebLib.FishUrlHelper.GetIntegerFromQueryString("categoryId", 0);
              if( result.CurrentCategoryId == 0 )
                  result.CurrentCategoryId = result.Categories[0].CategoryID;
      
              result.ProductInfoViewData = new ProductInfoViewData(result.Categories, 
      					new Product { CategoryID = result.CurrentCategoryId });
      
              result.PagingInfo.PageIndex = result.PagingInfo.GetPageIndex();
              result.PagingInfo.PageSize = AppHelper.DefaultPageSize;
      
              // 加載商品列表,并顯示
              result.Products = BllFactory.GetProductBLL().GetProductByCategoryId(result.CurrentCategoryId, result.PagingInfo);
              return result;
          }
      }
      
      
      public class ProductsPageData
      {
          public PagingInfo PagingInfo;
          public List<Category> Categories;
          public int CurrentCategoryId;
          public List<Product> Products;
      
          public ProductInfoViewData ProductInfoViewData { get; set; }
      
      
          public ProductsPageData()
          {
              this.PagingInfo = new PagingInfo();
          }
      }
      

      上面那個ascx是供JS調用的,C#的實現代碼如下:(注意是如何執行用戶控件的)

      /// <summary>
      /// 搜索訂單,并以HTML代碼的形式返回給客戶端
      /// </summary>
      /// <returns></returns>
      public static string Search()
      {
          // 從查詢字符串中讀取客戶端發過的日期范圍。
          QueryDateRange range = QueryDateRange.GetDateRangeFromQueryString("StartDate", "EndDate");
      
          OrderListViewData data = new OrderListViewData();
          data.PagingInfo.PageIndex = data.PagingInfo.GetPageIndex();
          data.PagingInfo.PageSize = AppHelper.DefaultPageSize;
      
          // 搜索數據庫
          data.List = BllFactory.GetOrderBLL().Search(range, data.PagingInfo);
      
          // 執行用戶控件,并傳遞所需的呈現數據。
          return FishWebLib.Ajax.UcExecutor.Execute("~/Controls/OrderList.ascx", data);
      }
      
      public class OrderListViewData
      {
          public List<OrderItem> List;
          public PagingInfo PagingInfo = new PagingInfo();
      }
      

      與Asp.net MVC框架一樣,頁面數據的加載和呈現徹底地分開了。

      JS調用上面那個ascx的代碼如下:

      function btnQuery_Click(){
          var dateRange = GetDateRange("txtStartDate", "txtEndDate");
          if( dateRange == null ) return false;
          var url = '/AjaxOrder.Search.cs?' 
      				+ $.param({StartDate: dateRange.StartDate, EndDate: dateRange.EndDate});
          ShowPickerPage(url, 'divResultList_inner', ShowResultSuccess);
          return false;
      }
      

      代碼回顧

      學過Asp.net MVC的朋友應該能發現,前面示例代碼中的 aspx, ascx的寫法,與Asp.net MVC的寫法是100%的兼容的。 但我肯定沒有使用Asp.net MVC,您可以下載示例代碼去看。

      當初學習Asp.net MVC是因為有些人把Asp.net MVC說得太過于神話了,好像用Asp.net做開發,非它不可。但是,學了之后才發現, 確實,這個東西有很多優點,但沒那么神奇。我認它最出色的地方還是在于它的思想:MVC,這種思想能夠讓我們在開發時, 盡量去分離一些可分離的東西,比如:呈現與獲取數據的過程,從而可以在一個地方只關注一件事情,也就是它所提倡的:分離關注點。

      正如前面所說,我認為Asp.net MVC的優點在于它的設計體現了MVC的思想。但讓人不解的是:微軟在實現時,不知為何, 非要把MVC搞得與WebForms差別巨大。這種區別尤其是在加入了Route和一堆Html擴展之后。 對于Route和一堆Html擴展,我對它們沒多大的興趣,因為它們于MVC無關,對于代碼的維護和性能根本沒什么改善。 所以也不打算在這個山寨版本上采用,反而認為現在的代碼更容易理解了。

      至于在Ajax方面的實現,我的框架也完全是符合MVC思想的。 而且在生成HTML片段時,仍然可以使用MVC的思想:先準備數據,然后交給ascx來呈現。

      我的MVC框架與Asp.net MVC的不同之處:
      1. 簡單了很多,拋棄了許多與MVC無關的東西。因此,學習成本更低。
      2. Controller少了很多限制,可以在單獨的類庫中實現。為了方便安全檢查,建議放在一個命名空間中,或者取個前綴或后綴,這也符合:約定勝于配置。
      3. 由于沒有Route,頁面是由Asp.net框架所調用的,而不是先經過Controller,但頁面的數據加載是由一個輔助的類來完成的, 這個類一定要實現一個名為“LoadModel”的方法(簽名不限,框架會識別),同樣,也是采用約定勝于配置的原則。

      點擊此處進入下載頁面

      posted on 2011-05-02 21:26  Fish Li  閱讀(14589)  評論(13)    收藏  舉報
      主站蜘蛛池模板: 亚洲精品一区二区动漫| 精品久久久久久成人AV| 亚洲国产一区二区精品专| 四虎永久播放地址免费| 免费观看日本污污ww网站69| 欧产日产国产精品精品| 农村妇女野外一区二区视频 | 亚洲女女女同性video| 性色av无码久久一区二区三区| 999福利激情视频| 高清国产精品人妻一区二区| 推特国产午夜福利在线观看 | 亚洲精品一区二区二三区| 国产av国片精品一区二区| 青青草无码免费一二三区| 精品人妻伦九区久久69| 性色欲情网站iwww| 国产精品视频全国免费观看| 久久成人 久久鬼色| 一区二区三区四区黄色片| 人妻中文字幕亚洲精品| 国产肉丝袜在线观看| 色秀网在线观看视频免费| 久久88香港三级台湾三级播放| 日韩中文日韩中文字幕亚| 青青草无码免费一二三区| 国产精品不卡一区二区在线| 国产精品亚洲二区在线播放| 国产午夜成人无码免费看| 国产成人综合亚洲欧美日韩| 亚洲色大成网站WWW永久麻豆| 国产成人综合在线观看不卡| 亚洲 都市 无码 校园 激情| 沙河市| 亚洲女同在线播放一区二区| 亚洲日韩久热中文字幕| 少妇人妻偷人偷人精品| 中文文精品字幕一区二区| 午夜大片免费男女爽爽影院| 亚洲人成影院在线观看| 免费无码av片在线观看网站|