GibboK
GibboK

Reputation: 74008

Razor and if statement

I'm using MS Razor in MVC 3 C#, I need to display some text "hello" within the IF statement. At the moment I receive an error. Any idea how to solve it?

EDIT: syntax error

   @if(Model.IsCustomEvent)
    {
        @Html.ActionLink("Edit", "Edit", new {  id=Model.EventTitle }) hello
    }

Upvotes: 0

Views: 7525

Answers (2)

codingbiz
codingbiz

Reputation: 26406

Use the @: symbol for including literals

@if(Model.IsCustomEvent)
{
    @Html.ActionLink("Edit", "Edit", new {  id=Model.EventTitle }) 
    @:hello
}

Upvotes: 4

Jayantha Lal Sirisena
Jayantha Lal Sirisena

Reputation: 21376

you need to put : before hello

 @if(Model.IsCustomEvent)
    {
        @Html.ActionLink("Edit", "Edit", new {  id=Model.EventTitle }) @:hello
    }

Here is a good reference

Upvotes: 8

Related Questions