开发者

Returning to the main view from a partial view when the partial view is invalid

开发者 https://www.devze.com 2023-03-03 22:58 出处:网络
My site will have partial views rendered on each page, to provide search functionality. As this is shared on several pages, and all new pages, I don\'t want to hard code anything or do anything pokin

My site will have partial views rendered on each page, to provide search functionality.

As this is shared on several pages, and all new pages, I don't want to hard code anything or do anything poking around the HTTP Context to determine which master view to render.

As such, I have two questions:

  1. How do I return to the main view that the partial view was contained in?
  2. How do I return the开发者_如何学JAVA partial view model to the main view so that I can correctly show an error message?

Now I realize I can render another full view, like a search results page with a message, but my preference is to have this rendered all in the partial view.

Thanks in advance.


Can the form in your partial view use ajax instead of performing a regular POST. Then you don't have to worry about where the request came from.

If the ajax post is successful you can redirect the user to the search results page.

0

精彩评论

暂无评论...
验证码 换一张
取 消