Sitecore MVC form postback does not return a full layout

前提是你 提交于 2019-12-24 03:35:20

问题


i'm using Sitecore 7 with MVC enabled. I have a cshtml layout that has a header, menu, footer and placeholder in it.

When i submit a form in the page with POST method, it gets to the controller and the controller is returning a viewresult for some reason only that particular html from the viewresult gets rendered to the page. Meaning that after doing a postback the header, menu, footer is gone and only the html from the result gets rendered on the page.

Is this behaviour expected or am i doing something wrong? i would expect that when i do form postback it would return the viewresult with the layout rendered as well


回答1:


i was supposed to use Html.BeginRouteForm instead of Html.BeginForm

adding this line fix the problem

   @using (Html.BeginRouteForm(Sitecore.Mvc.Configuration.MvcSettings.SitecoreRouteName, FormMethod.Post))
   {
      @Html.Sitecore().FormHandler()
   }


来源:https://stackoverflow.com/questions/17287910/sitecore-mvc-form-postback-does-not-return-a-full-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!