Note that there are some explanatory texts on larger screens.

plurals
  1. POReturning multiple views from single action in MVC3 & Razor
    primarykey
    data
    text
    <p>Scenario: There are three views (Razor) named "InvoiceBill", "Index", "Create". </p> <ol> <li>The Create view contains the form page for entering Invoice data.</li> <li>The Index page contains the list of all current date invoice bills.</li> <li>The InvoiceBill contains the code which generate the excel document (as an invoice report) based on this link (<a href="http://forums.asp.net/t/1711971.aspx/1" rel="nofollow">http://forums.asp.net/t/1711971.aspx/1</a>).</li> </ol> <p>Once i submit the form (Create view) it can post the form data to the DB (using EF). After the data inserted, it returns the Index page. </p> <p>But now i need to call the "InvoiceBill" view before calling Index page. </p> <pre><code>[HttpPost] public ActionResult Create(FormCollection collection, InvoiceViewModel INVViewModel) { if ((collection != null) &amp;&amp; (this.ModelState.IsValid)) { salesOrder.AccountNumber = INVViewModel.AccountNumber; salesOrder.BillToAddressID = INVViewModel.BillToAddressID; salesOrder.Comment = INVViewModel.Comment; salesOrder.ContactID = INVViewModel.ContactID; . . . . int sID = Using&lt;CreateSalesOrder&gt;().Execute(0, salesOrder); ***** From here i need to call the InvoiceBill page. Or guide me any other good way to achieve this return RedirectToAction("Index"); } } </code></pre> <p>Right now i am achieving this with some workarounds. But i feel that is not good. Please guide me how can i achieving this in a right way? Thanks</p> <p><strong>EDIT:</strong> </p> <pre><code>public ActionResult PrintInvoice(int id) { InvoiceReportViewModel invoiceReport = new InvoiceReportViewModel(); var soToView = Using&lt;GetSalesOrders&gt;().ExecuteForReport(id); invoiceReport.InvoiceBillName = "Invoice" + id.ToString(); invoiceReport.CustomerName = soToView.Customer.Name; invoiceReport.SalesOrderNumber = soToView.SalesOrderNumber; . . . . return View(invoiceReport); } </code></pre> <p>The InvoiceReport.cshtml</p> <pre><code>@model eItemBox.Web.Models.InvoiceReportViewModel @{ Layout = null; Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment; filename=" + Model.InvoiceBillName); //Content-Disposition is defined in RFC-2183 } &lt;Worksheet ss:Name="MyInvoice"&gt; . . . &lt;/Workbook&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload