Adding form in widget changes where main form tag closes
Hi,
Currently, we have a masterpage with structure as below:
<body>
<form>
<header></header>
...stuff...
<footer></footer>
</form>
</body>
However, when I add a form in an MVC widget to a page, the structure changes to this:
<body>
<form>
<header></header>
<SitefinityContent></SitefinityContent>
</form>
<footer></footer>
</body>
The structure above is explicitly stated in the master page and no changes are made to it when rendering the widget. Is there any way to keep the </form> from closing early?
Thanks,
Stuart
Hello
Stuart,I am not able to reproduce this issue on clean project. Can you please give me more information about the widget and the master page? It will be great if you can send them to me, so that i can test it locally.
Thank you for your cooperation.
Hi Kristian,
I ended up removing the form @using(Html.form()) that I had in MVC and just submitting the form that encompasses the entire body. I had to access the fields by name because there are some hidden fields that Sitefinity or ASP.NET apparently use, and it seems to be working. I am still curious about the issue though; how would I send you my files? If we ever need a more complex form, or a form that submits to a remote site, it might not be possible to rely on that 'body form' to automatically submit to the right place with the right fields.
Thanks,
Stuart
Hello Stuart,
Please have a look at http://www.sitefinity.com/documentation/documentationarticles/developers-guide/sitefinity-essentials/how-does-sitefinity-use-asp.net-mvc/three-mvc-modes/hybrid-mode
Instead of @Html.BeginForm you should be using @Html.BeginSitefinityForm. Try with that one and you shouldn't have problems with it.
However it will be best if you could submit a support ticket with your master page. In the support ticket we can provide you with out FTP server where you can upload your files.
Greetings,
Stoimen Stoimenov
the Telerik team
Hi Stoimen,
Is there a using statement or reference that I need to add so that @Html.BeginSitefinityForm is available?
I'm getting a System.Web.Mvc.HtmlHelper does not contain a definition for @Html.BeginSitefinityForm.
Hi Stuart,
You need to reference Telerik.Sitefinity.UI.MVC in your views.
@
using
Telerik.Sitefinity.UI.MVC
Hi Stoimen,
That fixed that. Thanks for the help!
Stuart