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?
You can add support for Pages to any ASP.NET Core MVC app by simply adding a Pages folder and adding Razor Pages files to this folder. Razor Pages use the folder structure as a convention for routing requests.
MVC works well with apps that have a lot of dynamic server views, single page apps, REST APIs, and AJAX calls. Razor Pages are perfect for simple pages that are read-only or do basic data input. MVC has been all the rage recently for web applications across most programming languages.
It is a server side markup language. Razor has no ties to ASP.NET MVC because Razor is a general-purpose templating engine. You can use it anywhere to generate output like HTML. It's just that ASP.NET MVC has implemented a view engine that allows us to use Razor inside of an MVC application to produce HTML.
What is a CSHTML file? A file with . cshtml extension is a C# HTML file that is used at server side by Razor Markup engine to render the webpage files to user's browser.
Try put @:
before your html code like this:
@for(int i=0;i< itemsCount; i++)
{
@: html code here
}
Alternatives:
1. wrap your html code with <text></text>
2. use HtmlHelper
to generate the html code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With