Fork me on GitHub

PagerOptions.HtmlAttributes property

Gets or sets the object that contains the HTML attributes to set for the MvcPager.

Syntax:

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

Default value:

null

Example:

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

This property value can also be set via the Options method as bellow:

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"))

Item can be added via AddHtmlAttribute(string key, object value) method:

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"))

Live demo:

@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;"} }))
FirstPrev12345678910...NextLast