I have this code (nested inside a form post) but am continually getting the error that it's missing the closing }
@for(int i=0;i< itemsCount; i++){
<input type="hidden" @string.Format("name= item_name_{0} value= {1}",i,items[i].Description) >
<input type="hidden" @string.Format("name= item_name_{0} value= {1}",i,items[i].UnitPrice.ToString("c"))>
}
I've been staring at it long enough...can anyone help?
try:
Note the changes / notes in prashanth's another as well.
Try put
@:
before your html code like this:Alternatives: 1. wrap your html code with
<text></text>
2. useHtmlHelper
to generate the html codeEasiest way is to make use of HTML Helpers. Code will be clean as well (your name format for Description and UnitPrice seems to follow the same format; you may want to change it)
you may note that for writing a code block you can write in two ways
In your case you can do as following
Or you can use the
Html.Raw
helperTry to enclose your for loop body between text tag.
http://weblogs.asp.net/scottgu/archive/2010/12/15/asp-net-mvc-3-razor-s-and-lt-text-gt-syntax.aspx