This is my ajax pager code below: Now I want to make sure that the link for the current page is unclickable and css should reflect that as well. My pager is keeping track of the current page number, so that is not a problem. The concern is how should I go about making that particular link unclickable and look different (without writing a bunch of crazy if-else blocks)?
<%if(Model.num_pages > 1){ %>
<table>
<tr>
<td><%=Model.Total%></td>
<td><%=Ajax.ActionLink("1",
Model.originalAction,
Model.originalController,
new { Page = 1, totalNumber = Model.Total, comments = (object)null, divToUpdate = Model.divToUpdate, videoId = Model.carrierId },
new AjaxOptions { UpdateTargetId = Model.divToUpdate, OnBegin = "commentBegin", OnComplete = "commentEnd" })%></td>
<%if (Model.num_pages > 3)
{ %>
<td>
<%using (Ajax.BeginForm(
Model.originalAction,
Model.originalController,
new {totalNumber = Model.Total, comments = (object)null, divToUpdate = Model.divToUpdate, videoId = Model.carrierId },
new AjaxOptions { UpdateTargetId = Model.divToUpdate, OnBegin = "commentBegin", OnComplete = "commentEnd" }))
{%>
<%=Html.DropDownList("Page", Model.dropDown)%>
<input value = "jump" type = "submit" />
<%} %>
</td>
<%} %>
<%else
{
for (int i = 2; i < Model.num_pages; i++)
{%>
<td>
<%=Ajax.ActionLink(i.ToString(),
Model.originalAction,
Model.originalController,
new { Page = i, totalNumber = Model.Total, comments = (object)null, divToUpdate = Model.divToUpdate, videoId = Model.carrierId},
new AjaxOptions { UpdateTargetId = Model.divToUpdate, OnBegin = "commentBegin", OnComplete = "commentEnd" })%>
</td>
<% }
}%>
<td><%=Ajax.ActionLink(Model.num_pages.ToString(),
Model.originalAction,
Model.originalController,
new { Page = Model.num_pages, totalNumber = Model.Total, comments = (object)null, divToUpdate = Model.divToUpdate, videoId = Model.carrierId},
new AjaxOptions { UpdateTargetId = Model.divToUpdate, OnBegin = "commentBegin", OnComplete = "commentEnd" })%></td>
</tr>
</table>
<%} %>
progtick – i think you’d be better off creating an htmlhelper for this. I’ve done this in the past with great success. basically, it’s a one liner:
and here’s how it looks (with unreserved apologies to SO for the obvious influence!!):
[update] you can grab a working example of this from here:
http://www.gatehousemusic.com/downloads/MvcApplication2.1.zip
let me know how you get on.