Reputation: 9855
Im working on a site built in .net - I have no idea how this works but I have the following...
<asp:DataPager ID="DP" runat="server" PagedControlID="LV" PageSize="5" QueryStringField="jobs">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
The above outputs my html as follows
<span id="ctl00_ContentPlaceHolder1_ctl00_ctl00_ctl00_DP">
<span>1</span>
<a href="link">2</a>
<a href="link">3</a>
<a href="link">4</a>
</span>
Is there a way to output this as or is it not possible?...
<div>
<span>
<a>
Upvotes: 0
Views: 617
Reputation: 41539
In your server control you can override the RenderBeginTag
method:
public override void RenderBeginTag(System.Web.UI.HtmlTextWriter writer)
{
writer.Write(String.Format("<div id=\"{0}\" class=\"{1}\">",
this.ClientID,this.CssClass));
}
Upvotes: 2
Reputation: 32323
As far as i know, DataPager
doesn't support it out of the box. But you can extend DataPager
class with overriding of the TagKey
property:
public class YourDataPager : DataPager
{
protected override HtmlTextWriterTag TagKey
{
get { return HtmlTextWriterTag.Div; }
}
}
Now YourDataPager
should outputs as a <div>
instead of <span>
.
Upvotes: 2
Reputation: 128781
Add a CssClass
to the <asp:DataPager>
:
<asp:DataPager CssClass="myCSSClass" ID="DP" runat="server" PagedControlID="LV" PageSize="5" QueryStringField="jobs">
And it should output:
<span id="ctl00_ContentPlaceHolder1_ctl00_ctl00_ctl00_DP" class="myCSSClass">
...and you can style accordingly from there.
Upvotes: 0