Home C# Razor View Error - Braces Expected
Reply: 0

C# Razor View Error - Braces Expected

user1821 Published in May 25, 2018, 11:11 am

Apologies, if this is very easy for some of you (if not everyone). I am a newbie in Razor view, so your help and support is highly appreciated.

I am receiving the following error:

} expected

in the Line 1. Here: @model ForExample.Models.DataClass

My Razor code:

@model ForExample.Models.DataClass

    ViewBag.Title = "Edit: " + @Model.Title;

@if(Model != null)

     if (@ViewBag.Message != "")
                var messageString = @ViewBag.Message;

                if (messageString.Contains("Successfully"))
                    <h3 style="color:green;">@ViewBag.Message</h3>
                    <h3 style="color:red;">@ViewBag.Message</h3>

        <form method="post">
            @Html.HiddenFor(model => model.Id)
            <h4>@Html.LabelFor(ex => ex.Title)</h4>
            <input type="text" id="Title" name="Title" class="form-control" value="@Model.Title" />
            <h4>@Html.LabelFor(ex => ex.Tags)</h4>
            <input type="text" id="Tags" name="Tags" class="form-control" value="@Model.Tags" />
            <h4>@Html.LabelFor(ex => ex.Description)</h4>
            <textarea id="Description" name="Description" class="form-control" rows="10" cols="100">@Model.Description</textarea><br />
            <button value="Example" id="Edit" class="btn btn-success btn-lg"> Save Changes </button>

Any idea what I might be missing? Thank you in advance!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30609 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO