New window opens on click of actionLink

后端 未结 6 1393
时光说笑
时光说笑 2021-01-05 20:18

I have a requirment to invoke a controller method from the view page. On click of the link below the method should be invoked.

@Html.ActionLink(item.InvoiceN         


        
6条回答
  •  时光取名叫无心
    2021-01-05 21:11

    Change your controller Action. The page that you get is blank because you are not returning anything. Do

     public ActionResult SendPdfStatement(string InvoiceNumber)
    
        {
        InvoiceNumber = InvoiceNumber.Trim();
    
            ObjectParameter[] parameters = new ObjectParameter[1];
            parameters[0] = new ObjectParameter("InvoiceNumber", InvoiceNumber);
    
            List list = new List();
            list = _db.ExecuteFunction("uspInvoiceStatement", parameters).ToList();
    
            var statementResult = _db.ExecuteFunction("uspInvoiceStatement", parameters);
            Models.Statement statement = statementResult.SingleOrDefault();
    
            pdfStatementController.WriteInTemplate(statement); 
    
        return View();
        }
    

    EDIT: Or you should use AJAX so that your page is not reloaded and you don't have to return anything from your method. Read here http://www.asp.net/mvc/overview/older-versions-1/contact-manager/iteration-7-add-ajax-functionality-cs.

提交回复
热议问题