2013-03-13 62 views
0

處理ASP MVC網絡應用程序。我有一個動態填充表來顯示搜索結果。 Chrome和FF的結果看起來不錯,但是在IE7中它增加了標題行之上的行。沒有添加源代碼,我可以在呈現的「頁面源代碼」中看到。IE呈現額外表格行

正如你在下面的圖片中看到的那樣,添加了一堆行(沒有內容)。如寫(在MVC)的HTML是:

<div class="detailSection"> 

<h2>Search Results</h2> 
<p style="font-size:1.2em; font-weight: bold;">Applicant: <%: Html.DisplayFor(m => m.NewPersonModel.FirstName) %> 
     <%: Html.DisplayFor(m => m.NewPersonModel.LastName) %></p> 

<p>Your search has returned the following results. If the current applicant has an existing record, 
     select the record and click the 'Compare' button at the end of the list.</p> 

    <% Html.BeginForm("Compare", "NewApplicant"); %> 

     <table id="s_ResultsTable" class="grid-striped"> 
      <tr> 
       <th>Select</th> 
       <th>First Name</th> 
       <th>Middle Name</th> 
       <th>Last Name</th> 
       <th>Date of Birth</th> 
       <th>Alias?</th> 
      </tr> 
       <% if (Model.PersonSearchModel.Count == 0) 
       { %> 
       <tr> 
        <td colspan="6">There are no matching volunteer records. <%: Html.ActionLink("Return to Detail page", "Detail", "NewApplicant", new { id = Model.NewPersonModel.ApplicantID }, null)%> to verify and save the application.</td> 
       </tr> 

       <%}%> 

       <% var rowCount = 0; 

        foreach (var item in Model.PersonSearchModel) 
        { %> 
        <tr class="row<%: rowCount++%2 +1 %>"> 
         <%: Html.HiddenFor(m => item.PersonID) %> 
         <%: Html.HiddenFor(m => m.NewPersonModel.ApplicantID) %> 
         <td class="resultsRadio"><%: Html.RadioButton("SelectedResult", item.PersonID) %></td> 
         <td><%: Html.DisplayFor(m => item.FirstName)%></td>       
         <td><%: Html.DisplayFor(m => item.MiddleName)%></td>       
         <td><%: Html.DisplayFor(m => item.LastName)%></td>       
         <td><%: Html.DisplayFor(m => item.DOB)%></td>              
         <td><%: Html.DisplayFor(m => item.IsAlias)%></td>              
        </tr> 
       <%}%> 
     </table> 
     <div id="searchButtonDiv"> 
      <input type="hidden" id="SelectedPerson" name="SelectedPerson" value="" /> 
      <input type="submit" id="submit" class="SKButton" value="Compare" /> 
    <input type="button" class="SKButton" value="Back to Detail" title="Return to detail page" onclick="location.href='<%:@Url.Action("Detail", "NewApplicant", new { id = Model.NewPersonModel.ApplicantID }) %>'" /> 

     </div> 
<% Html.EndForm(); %> 
</div> 

這使得在瀏覽器中:

<p>Your search has returned the following results. If the current applicant has an existing record, 
     select the record and click the 'Compare' button at the end of the list.</p> 


    <form action="/webapps/Eligibility/NewApplicant/Compare" method="post"> 

     <table id="s_ResultsTable" class="grid-striped"> 
      <tr> 
       <th>Select</th> 
       <th>First Name</th> 
       <th>Middle Name</th> 
       <th>Last Name</th> 
       <th>Date of Birth</th> 
       <th>Alias?</th> 
      </tr> 
        <tr class="row1"> 
         <input id="item_PersonID" name="item.PersonID" type="hidden" value="41838" /> 
         <input id="NewPersonModel_ApplicantID" name="NewPersonModel.ApplicantID" type="hidden" value="718" /> 
         <td class="resultsRadio"><input id="SelectedResult" name="SelectedResult" type="radio" value="41838" /></td> 
         <td>Steven</td>       
         <td></td>       
         <td>Amos</td>       
         <td>11/22/1977</td>              
         <td>No</td>              
        </tr> 

        <tr class="row2"> 
         <input id="item_PersonID" name="item.PersonID" type="hidden" value="54477" /> 
         <input id="NewPersonModel_ApplicantID" name="NewPersonModel.ApplicantID" type="hidden" value="718" /> 
         <td class="resultsRadio"><input id="SelectedResult" name="SelectedResult" type="radio" value="54477" /></td> 
         <td>Steven</td>       
         <td></td>       
         <td>Atkinson</td>       
         <td>09/23/1963</td>              
         <td>No</td>              
        </tr> 
     </table> 
     <div id="searchButtonDiv"> 
      <input type="hidden" id="SelectedPerson" name="SelectedPerson" value="" /> 
      <input type="submit" id="submit" class="SKButton" value="Compare" /> 
    <input type="button" class="SKButton" value="Back to Detail" title="Return to detail page" onclick="location.href='/webapps/Eligibility/NewApplicant/Detail/718'" /> 

     </div> 
</form> 
</div> 

Example of rendered page

這裏是在同一個頁面是如何呈現在其他任何瀏覽器:

Page as it should render:

任何想法爲什麼它會這樣做嗎?

EDITTED添加更多的代碼。我在呈現的源代碼中注意到的一件事是重複使用ID,這顯然應該是類。使用MVC Html幫助器設置ID,所以我正在研究如何阻止它做到這一點,並改變爲一個類。

+0

你可以發佈呈現的HTML嗎? – 2013-03-13 16:54:23

回答

3

有一些地方需要一些HTML。也許是一個未封閉的標籤,或類似的東西,大多數瀏覽器都會原諒它。

我會說盡可能多地去除頁面上的HTML,一次一點,直到看起來正常 - 這會找到你的罪魁禍首。

+1

我還會搜索錯位的標籤,或者您可能在某處打開了標籤,並意外將其關閉爲。 IE在這些事情上不是很好。 html的複製粘貼會很有幫助 – 2013-03-13 16:59:44

0

發現問題,它不喜歡標籤內的2個輸入,但不是任何種類的,等等。我把它們放在第一個裏面,一切都很好。

得罪部分:

<tr class="row2"> 
         <input id="item_PersonID" name="item.PersonID" type="hidden" value="163" /> 
         <input id="NewPersonModel_ApplicantID" name="NewPersonModel.ApplicantID" type="hidden" value="718" /> 
         <td class="resultsRadio"><input id="SelectedResult" name="SelectedResult" type="radio" value="163" /></td> 
         <td>steven</td>       
         <td></td>       
         <td>Terpin</td>       
         <td>04/14/1956</td>              
         <td>Yes</td>              
        </tr> 

現在更正爲:

     <tr class="row2"> 
         <td class="resultsRadio"><input id="SelectedResult" name="SelectedResult" type="radio" value="54477" /><input id="item_PersonID" name="item.PersonID" type="hidden" value="54477" /><input id="NewPersonModel_ApplicantID" name="NewPersonModel.ApplicantID" type="hidden" value="718" /></td> 
         <td>Steven</td>       
         <td></td>       
         <td>Atkinson</td>       
         <td>09/23/1963</td>              
         <td>No</td>              
        </tr> 

謝謝大家對你的建議。