Fork me on GitHub

MvcPager帮助文档 - PagerOptions.HtmlAttributes属性

获取或设置要应用到MvcPager的容器元素上的Html属性。

语法:

public IDictionary<string, object> HtmlAttributes {get; set;}

默认值:

null

用法示例:

@Html.Pager(Model,new PagerOptions{new Dictionary<string, object>{{"id","test"},{"style","font-weight:bold;"}} })

此属性也可通过MvcPager的Options扩展方法设置:

HtmlPager:

@Html.Pager(Model).Options(o => o.SetHtmlAttributes(new Dictionary<string, object>     {{ "style", "font-size:16px;text-align:right;"} }))

AjaxPager:

@Ajax.Pager(Model).Options(o=>o.SetHtmlAttributes(new Dictionary<string, object> {{ "style", "font-size:16px;text-align:right;"} })).AjaxOptions(a=>a.SetUpdateTargetId("target"))

也可通过AddHtmlAttribute(string key, object value)方法添加项:

HtmlPager:

@Html.Pager(Model).Options(o=>o.AddHtmlAttribute("style","font-size:16px"))

AjaxPager:

@Ajax.Pager(Model).Options(o=>o.AddHtmlAttribute("style","font-size:16px")).AjaxOptions(a=>a.SetUpdateTargetId("target"))

示例:

@Html.Pager(Model, new PagerOptions { HtmlAttributes = new Dictionary<string, object>{{"id","test"},{"style","font-weight:bold;"}} })

@Html.Pager(Model).Options(o => o.SetHtmlAttributes(new Dictionary<string, object> {{ "style", "font-size:16px;text-align:right;"} }))
首页上页...9101112131415161718...下页尾页