mvc - ajax pager - 使当前页面处于非活动状态链接

时间:2010-11-10 19:22:40

标签: javascript asp.net-mvc

这是我的下面的ajax寻呼机代码:现在我想确保当前页面的链接不可点击,css也应该反映出来。我的寻呼机正在跟踪当前页码,因此这不是问题。关注的是我应该如何使这个特定的链接不可点击并且看起来不同(没有写出一堆疯狂的if-else块)?

 <%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>
    <%} %>

1 个答案:

答案 0 :(得分:0)

progtick - 我认为你最好为此创建一个htmlhelper。我过去做过这个并取得了巨大的成功。基本上,这是一个班轮:

/* the 1st param is your target div
   the 2nd parameter true/false merely indicates whether
   the helper should run in querystring postback or ajax mode
*/
<%=Html.Pagination("TargetDiv", true) %>

以及它的外观(对于显而易见的影响,毫无保留的道歉!):

alt text

[更新] 您可以从此处获取相关的实例:

http://www.gatehousemusic.com/downloads/MvcApplication2.1.zip

让我知道你是怎么过的。