国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
ASP.NET MVC2右鍵菜單和最簡(jiǎn)單分頁(yè)-- .Net,資源天空 -- 領(lǐng)先的中文IT...

    右鍵菜單非常方便,很多時(shí)候會(huì)用到。這篇文章將使用一個(gè)JQUERY的插件在asp.net mvc中實(shí)現(xiàn)右鍵菜單。本文還將介紹一下在asp.net mvc中如何實(shí)現(xiàn)簡(jiǎn)單的分頁(yè)。效果如下圖:

    查看原圖(大圖)

    首先,下載此插件。

    新建一個(gè)asp.net mvc應(yīng)用程序。將此插件放入Scripts文件夾。并在頁(yè)面上引用。

    這個(gè)demo使用到NORTHWND數(shù)據(jù)庫(kù)的Product表。

    定義右鍵菜單:

    1 <div class="contextMenu" id="myMenu1">
    2 <ul>
    3 <li id="detail"><img src="http://www.cnblogs.com/Content/detail.ico" />detail</li>
    4 <li id="new"><img src="http://www.cnblogs.com/Content/new.ico" />new</li>
    5 <li id="delete"> <img src="http://www.cnblogs.com/Content/delete.ico"/>delete</li>
    6 <li id="modify"><img src="http://www.cnblogs.com/Content/modify.ico"/>modify</li>
    7 </ul>
    8 </div>

    將此菜單定義在產(chǎn)品名上,故在在產(chǎn)品名上添加一個(gè)class供jquery選擇。

    <td class="showContext" id="<%= item.ProductID %>"><%: item.ProductName %></td>

    在頁(yè)面上插入下面腳本。用于綁定菜單項(xiàng)的行為。為了簡(jiǎn)單起見(jiàn),將所以的菜單項(xiàng)的行為都定義成導(dǎo)航到詳情頁(yè)面。

    1 <script type="text/javascript">
    2
    3 $(document).ready(function () {
    4 $('td.showContext').contextMenu('myMenu1', {
    5 bindings: {
    6 'detail': function (t) {
    7 document.location.href = '/Products/Detail/'+t.id;
    8 },
    9 'new': function (t) {
    10 document.location.href = '/Products/Detail/' + t.id;
    11 },
    12 'delete': function (t) {
    13 confirm("你確定刪除嗎?");
    14 document.location.href = '/Products/Detail/' + t.id;
    15 },
    16 'modify': function (t) {
    17 document.location.href = '/Products/Detail/' + t.id;
    18 }
    19 }
    20 });
    21 });
    22
    23 </script>

    這樣就非常簡(jiǎn)單的實(shí)現(xiàn)了右鍵菜單的功能。

    下面說(shuō)下實(shí)現(xiàn)簡(jiǎn)單的分頁(yè)。asp.net mvc中分頁(yè)非常簡(jiǎn)單。

    看下面定義的table的html代碼:

    1 <table>
    2 <tr>
    3 <th>
    4 ProductName
    5 </th>
    6 <th>
    7 SupplierID
    8 </th>
    9 <th>
    10 CategoryID
    11 </th>
    12 <th>
    13 QuantityPerUnit
    14 </th>
    15 <th>
    16 UnitPrice
    17 </th>
    18 <th>
    19 UnitsInStock
    20 </th>
    21 <th>
    22 UnitsOnOrder
    23 </th>
    24 <th>
    25 ReorderLevel
    26 </th>
    27 <th>
    28 Discontinued
    29 </th>
    30 </tr>
    31
    32 <% foreach (var item in Model.Products)
    33 { %>
    34 <tr>
    35 <td class="showContext" id="<%= item.ProductID %>"><%: item.ProductName %></td>
    36 <td>
    37 <%: item.SupplierID %>
    38 </td>
    39 <td>
    40 <%: item.CategoryID %>
    41 </td>
    42 <td>
    43 <%: item.QuantityPerUnit %>
    44 </td>
    45 <td>
    46 <%: String.Format("{0:F}", item.UnitPrice) %>
    47 </td>
    48 <td>
    49 <%: item.UnitsInStock %>
    50 </td>
    51 <td>
    52 <%: item.UnitsOnOrder %>
    53 </td>
    54 <td>
    55 <%: item.ReorderLevel %>
    56 </td>
    57 <td>
    58 <%: item.Discontinued %>
    59 </td>
    60 </tr>
    61
    62 <% } %>
    63
    64 </table>

    我們只要在這個(gè)table下面插入一段分頁(yè)的HTML腳本就行了。分頁(yè)的腳本當(dāng)然要生成,使用Htmlhelper的擴(kuò)展方法去生成這個(gè)腳本。看下面的擴(kuò)展方法,非常的簡(jiǎn)單的生成了分頁(yè)的html代碼:

    1 public static string Pager(this HtmlHelper helper, int currentPage, int currentPageSize, int totalRecords, string urlPrefix)
    2 {
    3 StringBuilder sb1 = new StringBuilder();
    4
    5 int seed = currentPage % currentPageSize == 0 ? currentPage : currentPage - (currentPage % currentPageSize);
    6
    7 if (currentPage > 0)
    8 sb1.AppendLine(String.Format("<a href=\"{0}/{1}\">Previous</a>", urlPrefix, currentPage));
    9
    10 if (currentPage - currentPageSize >= 0)
    11 sb1.AppendLine(String.Format("<a href=\"{0}/{1}\">...</a>", urlPrefix, (currentPage - currentPageSize) + 1));
    12
    13 for (int i = seed; i < Math.Round((totalRecords / 10) + 0.5) && i < seed + currentPageSize; i++)
    14 {
    15 sb1.AppendLine(String.Format("<a href=\"{0}/{1}\">{1}</a>", urlPrefix, i + 1));
    16 }
    17
    18 if (currentPage + currentPageSize <= (Math.Round((totalRecords / 10) + 0.5) - 1))
    19 sb1.AppendLine(String.Format("<a href=\"{0}/{1}\">...</a>", urlPrefix, (currentPage + currentPageSize) + 1));
    20
    21 if (currentPage < (Math.Round((totalRecords / 10) + 0.5) - 1))
    22 sb1.AppendLine(String.Format("<a href=\"{0}/{1}\">Next</a>", urlPrefix, currentPage + 2));
    23
    24 return sb1.ToString();
    25 }

    然后在table后面添加下面的代碼,在table下面輸出分頁(yè)的html代碼:

    <div class="pager">
    <%=Html.Pager(Model.CurrentPage, Model.TotalPages,Model.TotalItems ,"/Products/List")%>
    </div>

    這樣就完成分頁(yè)和右鍵菜單的功能了。是不是非常的簡(jiǎn)單呢。:)

    效果:

    查看原圖(大圖)

    顯示:

    查看原圖(大圖)

    如果有興趣可以下載代碼。

    總結(jié):在asp.net mvc中實(shí)現(xiàn)右鍵菜單和簡(jiǎn)單的分頁(yè)。

    出處:http://zhuqil.cnblogs.com

    本文示例源代碼或素材下載

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
win10 IIS發(fā)布asp.net MVC網(wǎng)站
學(xué)習(xí)制作MVC4分頁(yè)控件(上)
有了jsRender,媽媽再也不用擔(dān)心我用jq拼接DOM拼接的一團(tuán)糟了、頁(yè)面整齊了、其他伙伴讀代碼也不那么費(fèi)勁了
ASP分頁(yè)技術(shù)源碼
DataList控件實(shí)現(xiàn)分頁(yè)功能
ASP.NET 數(shù)據(jù)列表控件的分頁(yè)總結(jié)(二):使用存儲(chǔ)過(guò)程分頁(yè)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服