MVC Pager控件的Ajax加载问题

时间:2011-09-28 13:51:34

标签: asp.net-mvc-3 asp.net-ajax

我们在视图上有一个MVC寻呼机控件,当移动到包含下一个,上一个或页码的新页面时,该页面会丢失所有CSS。寻呼机ajax将视图加载到它所处的div中。这是视图,移动页面到页面正确地激活控制器动作,但是当视图返回时,CSS消失了。任何帮助都很赞赏

<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl(Of PagedList(Of ClarifirePortal.PortalAnnouncement))" %>
<%@ Import Namespace="Webdiyer.WebControls.Mvc"  %>

<script type="text/javascript" >

    function gotoSearch() {

        window.location.href = '<%:URL.Action("Search","Home") %>';
    }

    function openDIV(divID) {

       var ele = document.getElementById(divID);

        if (ele.style.display == "block") {
            ele.style.display = "none";
          }
        else {
            ele.style.display = "block";
        }        
    }

</script>

<br />
<div id="divPortal">
<%If Model IsNot Nothing AndAlso Model.Count > 0 Then%>
    <br />
    <% Using Html.BeginForm("Search", "Home", FormMethod.Post, New With {.id = "PortalForm"})%>
        <table width="98%">
            <tr>
                <td>
                    <%: ViewData("WebStatus")%><br /><br />
                </td>
            </tr>            
            <tr>
                <td>
                    <% If ViewData("Enabled") = False Then%>
                        <input type="submit" value="Continue" class="t-button" name="Continue" onclick="gotoSearch(); return false;" />
                    <% End If%>
                </td>
            </tr>        
            <tr>
                <td>
                    <br />
                    <br />
                        <table width="100%" style="border: 2px solid #4675bb;">
                            <tr>
                                <td>
                                    Announcements
                                </td>
                            </tr>
                            <% For Each oAnnouncement As ClarifirePortal.PortalAnnouncement In Model%>
                            <tr>
                                <td align="left" style="width: 500px;"> <a href='void();' onclick='openDIV(<%:oAnnouncement.contentID %>); return false;' class="eMasonLink">
                                    <%: oAnnouncement.DatePosted & "-" & oAnnouncement.Title%></a><br />
                                    <%: oAnnouncement.ShortDescription%>
                                </td>
                            </tr>                              
                            <%Next%>                
                            <tr>
                                <td colspan="1">
                                    <%:Html.AjaxPager(Model, "LoadStatus", "Home", New PagerOptions() With {.PageIndexParameterName = "portalPage", .ShowDisabledPagerItems = False, .AlwaysShowFirstLastPageNumber = True}, New AjaxOptions With {.UpdateTargetId = "divPortal"})%>
                                </td>
                            </tr>
                        </table>
                </td>        
            </tr>         
         </table>                  
    <%End Using%>
<%Else %>  
    <br />
    <% Using Html.BeginForm()%>
    ...
    <%End Using%>
<%End If%> 
</div> 

1 个答案:

答案 0 :(得分:0)

有必要在我的视图中将脚本引用添加到不显眼的ajax文件中,修复它