Reputation: 4691
I'm trying something which should be easy
@Html.RadioButtonFor(m=>m.Prop, false) Option One
I am following the example on When using .net MVC RadioButtonFor(), how do you group so only one selection can be made?
The problem is, it doesn't render and I get an error message in the browser explaining it expects a ;
Why can't I have this? What do I need to do to show both words
Upvotes: 0
Views: 28
Reputation: 218782
You have to tell razor that "Option one" is a plain text you want to use in your html markup, not part of any C# statement/code you are executing. One way is to wrap that in an existing html element.
@Html.RadioButtonFor(m => m.Prop,"Detroit") <span>Option One</span>
Or Explicitly specify the non code part(plain text) using @:
tag when using with other code.
@Html.RadioButtonFor(m => m.Prop,"Detroit") @:Option One
Upvotes: 1