1
I’m doing a news site on ASP.NET MVC 5 and the need arose to see the Preview
of the news before saving it in the bank.
With a action
by name Preview
I can send the data to her and send it to a View
with the page design where the news will actually be shown, but lose the screen Create
.
How to make it open a new Tab with the Preview
and the screen of Create
remained intact?
I tried to do it this way, but two Actions with the MVC subscription does not allow. public Actionresult Create(Noticia noticia) {} [Httppost] public Actionresult Create(Noticia noticia) {}
– Hermes Autran
So, but note that I didn’t use the same name. A
Action
is calledPreview
(by the way, she has[HttpPost]
also) and the other is theCreate
(also with[HttpPost]
).– Leonel Sanches da Silva
And even when building your form, you change the target form to
_blank
before you submit that then you will see on another page and the current– Tafarel Chicotti
@gypsy-Morrison-Mendez I have Action Create by default, so I send this data to Action Preview right? Then send again to Action Create, but it does not let me receive with the News object because Create Httppost also receives this object and has the same name. At least here you’re making a mistake.
– Hermes Autran
@Hermesautran There it is: as I said in the answer, you have to put the fields in
hidden
and within a<form>
(preferably using@using (Html.BeginForm("Create", "Noticias"))
) so you can make a POST with the data.– Leonel Sanches da Silva