سؤال

How can I post a form to an HttPost Action method and open the returned View in a new window?

I've tried to find some way to do it using the window.open function and jQuery, but I can't find anything that works... It seems there should be an easy way to do this in MVC? Everything works fine returning a normal view from the post method, so all I need is to open that returned view in a new window instead (the posting page can simply stay as it is).

Any ideas?

هل كانت مفيدة؟

المحلول

<form method="post" action="yourcontroller" target="_blank">
 ...
</form>

Although specifying target="_blank" to open a new window is annoying to many users and makes your site less accessible, so use this only when you have a really good reason.

نصائح أخرى

Try this

<%:Html.BeginForm("Action", "Controller", FormMethod.Post, new { target = "_blank" })%>

stevehorn wrote a sample using jquery

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top