Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC3 Razor using Html.BeginForm problem

This is probably a simple thing, but ive got the following code:

<div>     @using (Html.BeginForm()) {         <p>             ...         </p>     } </div> 

And it keeps complaining that the starting { bracket must be followed by a end } bracket, but its there, and all code examples doing this sort of stuff show this as the way to do it, so im a bit baffled as to why it doesn't work...

like image 923
Grofit Avatar asked Feb 14 '11 09:02

Grofit


People also ask

What is HTML BeginForm ()?

"BeginForm()" is an extension method that writes an opening "<form>" tag to the response. "BeginForm()" is an extension method for both HtmlHelper and AjaxHelper classes.

What is the difference between Ajax BeginForm and HTML BeginForm?

Html. BeginForm() will create a form on the page that submits its values to the server as a synchronous HTTP request, refreshing the entire page in the process. Ajax. BeginForm() creates a form that submits its values using an asynchronous ajax request.

Why we use HTML BeginForm?

Html. BeginForm is the Html Helper Extension Method that is used for creating and rendering the form in HTML. This method makes your job easier in creating form. Here, is the method to create a form using Html.

Can we use multiple BeginForm in MVC?

Thanks for your help ! Multiple form tags should work fine in MVC unless they are nested.


1 Answers

Probably there is an error in the code within the <p> and </p> tags.

Try commenting it out and see what the result is:

<div>     @using (Html.BeginForm()) {         <p>                     @*  = Server side comment out.                     ....                     *@         </p>     } </div> 
like image 106
GvS Avatar answered Sep 25 '22 04:09

GvS