Link to home
Start Free TrialLog in
Avatar of suresh pondicherry
suresh pondicherryFlag for United States of America

asked on

MVC core open new window on button click

Hi All,
Am using MVC core. My controller has 3 action methods. One of the action method is opening pdf file in same page. I would like to open the pdf in new window. The below method opens new window but showing the error Bad Request - Invalid URL

 <td align='right'>
            <button id="PrintCmd" value="Print" class="btn btn-primary btn-sm">
                <span class="glyphicon glyphicon-print"></span> Print
            </button>
        </td></tr>


 $(document).ready(function () {

            $("#PrintCmd").click(function () {

                alert('test');
                var actionUrl = '<%= Url.Action("PDFForm", "PDFController" )%>';
                window.open(actionUrl);

             
            });
        });


Kind regards,
Pooja
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

 <td align='right'>
<a href="@Url.Action("PDFForm", "PDFController")" class="btn btn-primary btn-sm">
    Print
    <span class="glyphicon glyphicon-print" aria-hidden="true"></span>
</a>
</td></tr>

Open in new window

and do away with the script
Avatar of suresh pondicherry

ASKER

I need to open fresh window...
ASKER CERTIFIED SOLUTION
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
earlier i was using
var pData = document.getElementById('report').innerHTML;

now i need to get the report value in the controller portion of the code...
Correct solution