Asp.net-用vs2010创建自定义的HTML辅助类【GridView】,实现简单排序,分页

调用代码

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication1.Models.IndexModel>" %>
<%@ Import Namespace="MvcApplication1.Widia.DataControl.GridView" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <form id="form1" runat="server">

    <h2>我自定的GridView</h2>
    <%=Html.GridView(Model.listSQL,Model.currpage)%>
    </form>


</asp:Content>

 

执行后效果图

2010041617115562.jpg

1.使用静态方法创建HTML辅助类

using System;

namespace MvcApplication1.Helpers

{

           public class LabelHelper

           {

                public static string Label(string target, string text)

                {

                     return String.Format("<label for='{0}'>{1}</label>", target, text);

                }

           }

}

 

2.使用扩展方法创建HTML辅助类

using System;

using System.Web.Mvc;

 

namespace MvcApplication1.Helpers

{

      public static class LabelExtensions

      {

           public static string Label(this HtmlHelper helper, string target, string text)

           {

                return String.Format("<label for='{0}'>{1}</label>", target, text);

           }

      }

s}

转载于:https://www.cnblogs.com/widia/archive/2010/04/16/1713736.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值