Dollar sign and/or Dash breaking Razor's parser

Posted by justSteve on Stack Overflow See other posts from Stack Overflow or by justSteve
Published on 2010-12-30T11:27:14Z Indexed on 2010/12/30 12:53 UTC
Read the original article Hit count: 173

Filed under:
|

the end-result i'm trying to render:

<input type="radio" name="options" id="options_1" />$1 - A Not Very Expensive Chocolate
<input type="radio" name="options" id="options_2" />$10 - A Kinda Expensive Chocolate
<input type="radio" name="options" id="options_3" />$100 - A Really Expensive Chocolate

From this code:

@foreach (var o in Model.Options){
    <input type="radio" name="options" id=@("options_" + @o.ID) />[email protected] - @o.Label
}

If i drop both the '$' and the '-' from what should be plain old text - stuff works. Adding either resulted in compiler warnings and runtime errors. I've tried the explicit syntax as described here but haven't found the right combination yet.

© Stack Overflow or respective owner

Related posts about asp.net-mvc-3

Related posts about Razor