Sunday 30 December 2012

The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.


Many time some people ask this question in asp.net forums.
for
Error: The if block is missing a closing "}" character.  Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.

@model IEnumerable<GuestbookApp.Models.Guestbook>
@{
    ViewBag.Title = "Guestbook";
}

<h2>Guestbook</h2>
@Html.ActionLink("Sign Guestbook", "Sign")
<hr />
@if (ViewBag.Result != null)
{
    if (ViewBag.Result == "success")
    {
        <div style="border: 1px #138b0e solid; background-color: #deffe0">
    }
    else
    {
        <div style="border: 1px #ff6a00 solid; background-color: #fcc7c7">
    }
        @ViewBag.Msg
    </div>
}
<table border="0" cellpadding="4" cellspacing="2">

...Where did I go wrong? that's the right if-else statement right? or is there I miss in Razor rules? Please help.. thanks..


How to solve??


Solving code
add this @: in front of div(or any)  open and close tag in used if conditions.

for above code issu was solved by,watch below

 if (ViewBag.Result == "success")
    {
        @:<div style="border: 1px #138b0e solid; background-color: #deffe0">
    }
    else
    {
       @:<div style="border: 1px #ff6a00 solid; background-color: #fcc7c7">
    }
        @ViewBag.Msg
    @:</div>

and all of you must refer this

1 comment:

  1. This blog is so informative for providing a valuable information about send sms api c#.

    ReplyDelete

If any doubt?then please comment in my post

How to reduce angular CLI build time

 Index: ----- I am using angular cli - 7 and I am going to tell how to reduce the build time as per my knowledge. Problem: -------- Now the ...