Rakin
Rakin

Reputation: 1279

Encountered end tag "tr" with no matching start tag. Are your start/end tags properly balanced?

I have the following code/markup

@for (int m = 0; m < Model.Parts.Count; m++ ) {
    var item2 = Model.Parts[m];
    <tr id='@item2.WorkOrderPartId'>
        <td></td>
        <td style='text-align:center'> @item2.LineNo </td>
        <td> @item2.SalesOrderLineNo</td> 
        <td style='text-align:center'>
            @item2.Length
        </td> 
        <td style='width:100px;text-align:right'>
          </td> 
        <td style='width:100px;text-align:left'>
         </td>
         </td>
        <td style='padding-right:10px'>0</td>
        <td style='padding-right:10px'>0</td> 
    <td class='RemainingWeight'></td>
    <td>  </td> 
        </tr>
}

When this view get executed following error is getting OnException.

Encountered end tag "tr" with no matching start tag. Are your start/end tags properly balanced?

Please helpme? :(

Upvotes: 0

Views: 3552

Answers (4)

Abhilash Augustine
Abhilash Augustine

Reputation: 4208

I am not sure is this solve your problem.

Anyway you can just try this code.

@for (int m = 0; m < Model.Parts.Count; m++)
{
    var item2 = Model.Parts[m];
    <tr id='@item2.WorkOrderPartId'>
        <td></td>
        <td style='text-align:center'> @item2.LineNo </td>
        <td> @item2.SalesOrderLineNo</td>
        <td style='text-align:center'>
            @item2.Length
        </td>
        <td style='width:100px;text-align:right'></td>
        <td style='width:100px;text-align:left'></td>
        <td style='padding-right:10px'>0</td>
        <td style='padding-right:10px'>0</td>
        <td class='RemainingWeight'></td>
        <td>  </td>
    </tr>
}

There was an extra closing td tag in your code.

Upvotes: 2

CThakur
CThakur

Reputation: 136

In case of this code block only You have one extra td end tag that is:

<td style='width:100px;text-align:left'>
         </td>
         </td>

... Athough to detect in future If you are using visual studio then click on the starting tag of a it will highlight the corresponding end Tag. If it doesn't highlight an end tag for one of the starting tag then that one is missing the end tag.

Upvotes: 2

Saurav
Saurav

Reputation: 118

There is an additional end tag without a start tag for the same in the code you have shared. The one marked in ** below from your code snippet.

<td style='width:100px;text-align:left'>
     </td>
     **</td>**

Upvotes: 2

Steyn
Steyn

Reputation: 1321

Good indentation is the key to success.

@for (int m = 0; m < Model.Parts.Count; m++ ) {
    var item2 = Model.Parts[m];
    <tr id='@item2.WorkOrderPartId'>
        <td></td>
        <td style='text-align:center'> @item2.LineNo </td>
        <td> @item2.SalesOrderLineNo</td> 
        <td style='text-align:center'>
            @item2.Length
        </td> 
        <td style='width:100px;text-align:right'></td> 
        <td style='width:100px;text-align:left'></td>
        <td style='padding-right:10px'>0</td>
        <td style='padding-right:10px'>0</td> 
        <td class='RemainingWeight'></td>
        <td></td> 
    </tr>
}

You had

<td style='width:100px;text-align:left'>
         </td>
         </td>

Which should just be

 <td style='width:100px;text-align:left'></td>

Upvotes: 5

Related Questions