Here's the situation.
I have a save, and a print button :
<input name="btnSubmit" type="submit" value="Save" />
<input name="btnSubmit" type="submit" value="Print"/> @*Redirect to Action("Print", "controler")*@
But the print button has to open a new tab. If it was just me, I obviously know I have to save before printing... it would not be an issue. I could use this link with target blank instead :
<a target="_blank" href="@Url.Action("Print", "controler", new { id = Model.id })" type="submit" value="Print" > Print</a>
Easy, but now some users think that the print button should ALSO save the page. Because they don't push save... they just print and the model changes are lost because I can't call the post action in my print link... it's a link.
I thought, at first, that I could make an asynchronous call to a save fonction, but my model is way too big, it requires the post back of it's own action (right ?)
Went through this :
How do I use Target=_blank on a response.redirect?
And i'm not sure if it really help in MVC... right now i'm stuck here :
[HttpPost]
public ActionResult MyForm(string btnSubmit, formModel model)
{
if (btnSubmit == "Print")
{
dbSave(model);
return RedirectToAction("Print", "controler"); // Won't open new tab...
}
}