ASP.NET MVC仅呈现自定义控件

时间:2015-07-16 15:19:04

标签: asp.net-mvc view kendo-ui telerik kendo-asp.net-mvc

我一直在争论这个问题超过一个星期,20个开发人员无法弄清楚发生了什么。我希望以前有人见过这个问题。

免责声明:该网站是一个政府网站,它的密码受到安全网络的保护,所以不幸的是,我无法提供链接。但我会尽力解释。如果您需要任何特定代码,我可以提供。我只是不想用很多无用的代码来混淆这个问题。这就是它。

  • 环境:ASP.NET MVC
  • 控制:Kendo Telerik
  • 架构:布局>意见>部分观点

有问题的屏幕是搜索结果屏幕。应用程序运行时,它会继承_SharedLayout。在此布局(母版页)内部是视图的位置。在这种情况下,Search.vbhtml视图。到目前为止,页面没有问题。当我在搜索框中输入信息并运行搜索按钮时,会出现问题。 View连接到数据库,它返回数据但_SharedLayout和Search View不呈现。检查浏览器后,我注意到以下内容

<html>
  <head> NOTHING HERE</head>
  <body>
      WHERE IS THE REST OF THE PAGE? LAYOUT AND SEARCH VIEW
      <div>
         Search result control forms and tables and all the good stuff 
      </div>
      FOOTER IS MISSING TOO
  </body>
</html>

当然,如果在页面的头部没有任何引用,搜索结果视图就会输出无样式(就像它获得的那样)

以下是搜索视图的代码(生成结果的按钮所在的位置)。就像我上面说的那样,如果你需要控制器代码或其他任何我会尽力提供它

@Modeltype IndividualSearchViewModel

@Code
   Layout = Nothing
   ViewData("Title") = "Search Individual"
   ViewData("PageName") = "Search Individual"
   Dim isPopupMode As String = "N"
   Dim ajaxAction = New AjaxOptions With {.HttpMethod = "post", .UpdateTargetId = "IndividualSearchContent", .InsertionMode = InsertionMode.Replace}

   If Not Model.Mode Is Nothing AndAlso Model.Mode.Equals("popup", StringComparison.CurrentCultureIgnoreCase) Then
      isPopupMode = "Y"
      ajaxAction.OnBegin = "OnPopupRequestBegin('IndividualSearchContent')"
      ajaxAction.OnComplete = "OnPopupRequestComplete('IndividualSearchContent')"
   Else
      ajaxAction.OnBegin = "OnPageRequestBegin"
      ajaxAction.OnComplete = "OnPageRequestComplete"
   End If

   End Code

   <div id="IndividualSearchContent">
       @Using Ajax.BeginForm("Index", "IndividualSearch", ajaxAction, New With {.role = "form"})
       @<div class="searchCriteriaDivCss @(If(isPopupMode = "Y", "hidden", ""))">
       @Html.ValidationSummary(False, "", New With {.class = "text-danger"})
    </div>

    @<div class="form-horizontal">
         @If Model.Messages IsNot Nothing Then
             @<div id="ValidationMessages" class="form-group text-center">
                 @For Each message In Model.Messages
                     @<b>@message</b>
                     @<br />
                 Next
             </div>
             @<br />
         End If


    <div class="row">
      <div class="col-xs-12">

        <div class="form-group">
            @Html.LabelFor(Function(m) m.IdentifierType, New With {.class = "col-md-3 col-sm-12 col-xs-12"})
            <div class="col-md-3 col-sm-12 col-xs-12">
                @Html.Kendo.DropDownListFor(Function(m) m.IdentifierTypeValue).HtmlAttributes(New With {.class = "form-control"}).BindTo(Model.IdentifierType).OptionLabel("Select One")
            </div>

            @Html.LabelFor(Function(m) m.Identifier, New With {.class = "col-md-3 col-sm-12 col-xs-12"})
            <div class="col-md-3 col-sm-12 col-xs-12">
                @Html.Kendo.MaskedTextBoxFor(Function(m) m.Identifier).Mask("#########").HtmlAttributes(New With {.class = "form-control"})
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(Function(m) m.LastName, New With {.class = "col-md-3 col-sm-12 col-xs-12"})
            <div class="col-md-3 col-sm-12 col-xs-12">
                @Html.TextBoxFor(Function(m) m.LastName, htmlAttributes:=New With {Key .maxlength = "50", .class = "form-control"})
            </div>

            @Html.LabelFor(Function(m) m.FirstName, New With {.class = "col-md-3 col-sm-12 col-xs-12"})
            <div class="col-md-3 col-sm-12 col-xs-12">
                @Html.TextBoxFor(Function(m) m.FirstName, htmlAttributes:=New With {Key .maxlength = "50", .class = "form-control"})
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(Function(m) m.IndividualDOB, New With {.class = "col-md-3 col-sm-12 col-xs-12"})
            <div class="col-md-3 col-sm-12 col-xs-12">
                @Html.Kendo.DatePickerFor(Function(m) m.IndividualDOB).Max(Date.Today).HtmlAttributes(New With {.class = "form-control", .maxlength = "10"})
            </div>

            @Html.Label("Residential County:", New With {.class = "col-md-3 col-sm-12 col-xs-12"})
            <div class="col-md-3 col-sm-12 col-xs-12">
                @Html.Kendo.DropDownListFor(Function(m) m.ResidentialCounty).BindTo(Model.ResidentialCountyOptions).OptionLabel("Select One").HtmlAttributes(New With {.class = "form-control"})
            </div>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-xs-12 text-center submitButtons">
            @Html.Kendo.Button().Name("Clear").Content("Clear <i class='fa fa-times'></i>").HtmlAttributes(New With {.type = "submit", .name = "SubmitAction", .id = "clear", .value = "clear", .class = "btn-primary"})
            @Html.Kendo.Button().Name("Search").Content("Search <i class='fa fa-search'></i>").HtmlAttributes(New With {.type = "submit", .name = "SubmitAction", .id = "search", .value = "search", .class = "btn-green"})
        </div>
      </div>
      <div class="row">
        <div class="col-xs-12">
            <div class="form-group text-center">
                 &nbsp;
            </div>
        </div>
      </div>

      @If Model.SearchResults Is Nothing Then
        @<div class="row">
          <div class="col-xs-12">
            <div class="form-group text-center complaintDetailButtons">
                @Html.Kendo.Button().Name("NoIndividual").Content("<span>Continue Without Selecting<br> an Individual</span> <i class='fa fa-arrow-right'></i>").HtmlAttributes(New With {.id = "btnNoIndividual", .class = "btn btn-primary btn-xl long-wrap", .value = "noindividual"})
            </div>
          </div>
       </div>

       End If

       @If (Model.SearchResults Is Nothing OrElse Model.SearchResults.Count = 0) AndAlso (Model.ProgramOffices IsNot Nothing AndAlso Model.ProgramOffices.Contains(EIM.BO.Enumerators.ProgramOffice.ODP)) AndAlso (Model.IsLicensed) Then
          @<div class="row">
              <div class="col-xs-12">   
          @Html.Kendo.Button().Name("NoMCI").ImageUrl(Url.Content("~/Content/Images/buttons/noMCI.jpg")).HtmlAttributes(New With {.id = "btnNoMCI", .value = "nomci"})
              </div>
          </div>
       End If

       @If Not Model.SearchResults Is Nothing AndAlso Model.SearchResults.Count > 0 Then
        @<div class="row" id="resultsGrid">
            <div class="col-xs-12">
                 @(Html.Kendo.Grid(Of IndividualSearchResultViewModel)(Model.SearchResults).
                                Name("SearchIndivResults").
                                Sortable(Function(s) s.AllowUnsort(False)).
                                Filterable().
                                Scrollable(Sub(s) s.Height("100%")).
                                Columns(Sub(c)
                                            c.Bound(Function(m) m.MCI).ClientTemplate("<a href='' class='MCILink' id='#:MCI#_#:IndividualResultId#_#:ProgramOffice#'>#=MCI#</a>")
                                            c.Bound(Function(m) m.SSN)
                                            c.Bound(Function(m) m.Name).HtmlAttributes(New With {.class = "MCIName"})
                                            c.Bound(Function(m) m.DOB)
                                            c.Bound(Function(m) m.ResidentialCounty)
                                            c.Bound(Function(m) m.ProgramOffice)
                                            c.Bound(Function(m) m.WaiverName)
                                            c.Bound(Function(m) m.ProgramEffectiveDates)
                                            c.Bound(Function(m) m.SourceSystem).Hidden()
                                            c.Bound(Function(m) m.Line1).Hidden()
                                            c.Bound(Function(m) m.Line2).Hidden()
                                            c.Bound(Function(m) m.Line3).Hidden()
                                            c.Bound(Function(m) m.MI).Hidden()
                                            c.Bound(Function(m) m.Suffix).Hidden()
                                            c.Bound(Function(m) m.Gender).Hidden()
                                            c.Bound(Function(m) m.Phone).Hidden()
                                            c.Bound(Function(m) m.Email).Hidden()
                                            c.Bound(Function(m) m.City).Hidden()
                                            c.Bound(Function(m) m.State).Hidden()
                                            c.Bound(Function(m) m.Zip).Hidden()
                                            c.Bound(Function(m) m.FirstName).Hidden()
                                            c.Bound(Function(m) m.LastName).Hidden()
                                            c.Bound(Function(m) m.SourceSystemKey).Hidden()
                                            c.Bound(Function(m) m.IndividualResultId).Hidden()
                                            c.Bound(Function(m) m.SCEntityName).Hidden()
                                            c.Bound(Function(m) m.SCFirstName).Hidden()
                                            c.Bound(Function(m) m.SCLastName).Hidden()
                                            c.Bound(Function(m) m.SCPhone).Hidden()
                                            c.Bound(Function(m) m.HiddenDOB).Hidden()
                                            c.Bound(Function(m) m.FundingCounty).Hidden()
                                            c.Bound(Function(m) m.Region).Hidden()
                                            c.Bound(Function(m) m.BSU).Hidden()
                                            c.Bound(Function(m) m.AssignedSCUserID).Hidden()
                                            c.Bound(Function(m) m.AssignedSCSupervisorUserID).Hidden()

                                        End Sub).
                                DataSource(Sub(s) s.Ajax().ServerOperation(False)))
             </div>
          </div>
        End If

        @Html.HiddenFor(Function(m) m.Mode)
        @Html.Hidden("SelectedMciNum")
        @Html.Hidden("SelectedSSN")
        @Html.Hidden("SelectedName")
        @Html.Hidden("SelectedDOB")
        @Html.Hidden("SelectedFirstName")
        @Html.Hidden("SelectedLastName")
        @Html.HiddenFor(Function(m) m.FilingOrganizationFilter)

        <input type="hidden" id="CallingPage" name="CallingPage" value="@Model.CallingPage" />
     </div>

     End Using
   </div>


   <script type="text/javascript">

      $(document).ready(function () {

        $(this).keypress(function (e) {
          if (e.keyCode == 13) {
            $('#search').click();
            e.preventDefault();
          }
        })

      $("#Search").focus();

      $("#Identifier:text").on("focus", function () {
         var input = $(this);
         setTimeout(function () { input.select(); });
      });

      var errortext = "@Model.errorText"

      if(errortext != "")
        {
          var errorarray = errortext.split('~');
          var errormsg = "";
          for (var i = 0; i <errorarray.length; i++)
          {
            errormsg += errorarray[i] + '<br/>';
          }
          errortext = errormsg.substring(0, errormsg.length - 5);
        }
        $("#kendoValidatorField").html(errortext);

        var pageComingFrom = sessionStorage.getItem("pageComingFrom");
        var isPopUp = '@isPopupMode';

        if (pageComingFrom == "null" || isPopUp == 'Y') {
          var btnNoIndiv = $("#btnNoIndividual");
          btnNoIndiv.hide();
        }

        var filingOrganization = sessionStorage.getItem("filingOrganization");

        //clear sessionStorage
        sessionStorage.removeItem("filingOrganization");
        if (!filingOrganization) {
          filingOrganization = $("#FilingOrganization").val();
        }

    if (filingOrganization) {
          $("#FilingOrganizationFilter").val(filingOrganization);
    }


    $("div#IndividualSearchContent").on("click", "a.MCILink", function (e) {
        sessionStorage.setItem("IsContinueWithOutSelectingClicked", "No")
        if ($('#IndividualMCI') && $('#IndividualMCI').length > 0) {
            $('#IndividualMCI').val($(this).text());
            $('#IndividualMCIDiv').html($('#IndividualMCI')[0].value)
            $('#IndividualName').val($(this)[0].parentNode.nextSibling.nextSibling.innerText);
            $('#IndividualNameDiv').html($('#IndividualName')[0].value);
        }

        var dataToSend;
        var gridData = $("#SearchIndivResults").data("kendoGrid");
        if (gridData != null) {
            var selectedItem = this.id;

            var value = gridData._data.length;
            for (var i = 0; i < value; i++) {
                var item = gridData._data[i];
                var selectedItemRecord = item.MCI +'_'+ item.IndividualResultId+'_'+item.ProgramOffice
                if (selectedItemRecord == selectedItem) {
                    dataToSend = item;
                                           sessionStorage.setItem("selectedItemDOB", dataToSend.HiddenDOB.split(" ")[0])
                                           sessionStorage.setItem("selectedItemMCI", dataToSend.MCI)
                                           sessionStorage.setItem("selectedItemName", dataToSend.Name)
                                           sessionStorage.setItem("selectedItemProgEffDt", dataToSend.ProgramEffectiveDates)
                                           sessionStorage.setItem("selectedItemPO", dataToSend.ProgramOffice)
                                           sessionStorage.setItem("selectedItemSS", dataToSend.SourceSystem)
                                           sessionStorage.setItem("selectedItemSSKey", dataToSend.SourceSystemKey)
                                           sessionStorage.setItem("selectedItemSSN", dataToSend.SSN)
                                           sessionStorage.setItem("selectedItemWaiver", dataToSend.Waiver)

                                           sessionStorage.setItem("selectedItemLine1", dataToSend.Line1)
                                           sessionStorage.setItem("selectedItemLine2", dataToSend.Line2)
                                           sessionStorage.setItem("selectedItemLine3", dataToSend.Line3)
                                           sessionStorage.setItem("selectedItemMI", dataToSend.MI)
                                           sessionStorage.setItem("selectedItemSuffix", dataToSend.Suffix)
                                           sessionStorage.setItem("selectedItemGender", dataToSend.Gender)
                                           sessionStorage.setItem("selectedItemPhone", dataToSend.Phone)
                                           sessionStorage.setItem("selectedItemEmail", dataToSend.Email)
                                           sessionStorage.setItem("selectedItemCity", dataToSend.City)                                               
                                           sessionStorage.setItem("selectedItemCounty", dataToSend.ResidentialCounty)
                                           sessionStorage.setItem("selectedItemFundingCounty", dataToSend.FundingCounty)
                                           sessionStorage.setItem("selectedItemRegion", dataToSend.Region)
                                           sessionStorage.setItem("selectedItemState", dataToSend.State)
                                           sessionStorage.setItem("selectedItemZip", dataToSend.Zip)
                                           sessionStorage.setItem("selectedItemIndividualResultId", dataToSend.IndividualResultId)                                             
                                           sessionStorage.setItem("selectedItemSCEntityName", dataToSend.SCEntityName)
                                           sessionStorage.setItem("selectedItemSCFirstName", dataToSend.SCFirstName)
                                           sessionStorage.setItem("selectedItemSCLastName", dataToSend.SCLastName)
                                           sessionStorage.setItem("selectedItemSCPhone", dataToSend.SCPhone)
                                           sessionStorage.setItem("selectedItemHiddenDOB", dataToSend.HiddenDOB)
                                           sessionStorage.setItem("selectedBSU", dataToSend.BSU)
                                           sessionStorage.setItem("selectedAssignedSCUserID", dataToSend.AssignedSCUserID)
                                           sessionStorage.setItem("selectedAssignedSCSupervisorUserID", dataToSend.AssignedSCSupervisorUserID)

                }
            }
        }


        $("#SelectedMciNum").val($(this).text());
        if ($("#IndividualSearchWindow").data("kendoWindow")) {
          $("#IndividualSearchWindow").data("kendoWindow").close();
        }


        e.preventDefault();
      })

      $('#btnNoIndividual').click(function (e) {
         sessionStorage.setItem("IsContinueWithOutSelectingClicked", "Yes")
         window.location.href = baseUrl + "ComplaintIndividualInformation/Index";
      })

      $('#btnNoMCI').click(function (e) {
          window.location.href = baseUrl + "IndividualDetail/IndividualHasNoMCI";
      })

      ValidateTextDate();
   });

   </script>

P.S。对我来说最奇怪的是,在IE9中,它都按预期显示。但是在Chrome或FF中没有运气。

我真的很感激你的帮助。

0 个答案:

没有答案