I have a requirement to call the controller method from the view page. When you click the link below, the method should be called.
@Html.ActionLink(item.InvoiceNumber, "SendPdfStatement", "Invoice",
new { item.InvoiceNumber }, new { target = "_blank" })
The method signature looks like this:
public void SendPdfStatement(string InvoiceNumber)
{
InvoiceNumber = InvoiceNumber.Trim();
ObjectParameter[] parameters = new ObjectParameter[1];
parameters[0] = new ObjectParameter("InvoiceNumber", InvoiceNumber);
List<Models.Statement> list = new List<Models.Statement>();
list = _db.ExecuteFunction<Models.Statement>("uspInvoiceStatement", parameters).ToList<Models.Statement>();
var statementResult = _db.ExecuteFunction<Models.Statement>("uspInvoiceStatement", parameters);
Models.Statement statement = statementResult.SingleOrDefault();
pdfStatementController.WriteInTemplate(statement);
}
Now the problem is when I click on the link, an empty window opens. I know this is something with new { target = "_blank" }. If I submit null, then my page with the link will be empty. What can I pass so that my page remains as it is, and a new blank window does not appear.
source
share