Encountered end tag "div" with no matching start tag Are your start end tags properly balanced


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

Why is this error happening, I do have all the div's and their closing #tags in place. What is going on?


Login to See the Rest of the Answer

Answer: There is a chance that you have open and close brackets with an "@" symbol in front of it. If you have an open and close bracket with an "at" symbol in front, it tells the #Razor #Compiler that the following code is #C-Sharp therefore the immidiete closing div tag might not be taken into the account.

1. One way to resolve this issue is by removing the Open and Closing brackets and just use the "at" symbol.

   #For example: 
 

   <div class="col border d-flex flex-row justify-content-between">
              <a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-lg btn-warning m-2">
            <img class="img-fluid" src="~/img/icons/fi-page-edit.svg" />
            Edit</a>
          
            @{
              if(Model.Active == false){
              <a asp-action="Delete" asp-route-id="@Model.Id" class="btn btn-lg btn-danger m-2">
            <img class="img-fluid" src="~/img/icons/fi-page-delete.svg" />Delete</a>
              }

              </div><!--This tag might not be recognized by the Razor Compiler that it is a closing tag. -->

Instead you should try writing your #code like below:

   <div class="col border d-flex flex-row justify-content-between">
              <a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-lg btn-warning m-2">
            <img class="img-fluid" src="~/img/icons/fi-page-edit.svg" /> Edit</a>
          
              @if(Model.Active == false){
              <a asp-action="Delete" asp-route-id="@Model.Id" class="btn btn-lg btn-danger m-2">
            <img class="img-fluid" src="~/img/icons/fi-page-delete.svg" />
            Delete</a>
              }

              </div>

2. If the above step did not help you, take a deeper look and there is a chance that you have the div closing tag in a wrong place. If you have open and close brackets like in step 1, make sure that the closing div tag in placed in a correct place.

I hope this helped you, if it did go ahead and leave a comment below to let others that the solution actually helped you.






© 2024 - ErnesTech - Privacy
E-Commerce Return Policy