Click here to Skip to main content
15,868,048 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have list page and add/edit page of list page.When i will Add/Edit any data then on button click there is alert message of printing data.

1. If user will click on "yes" then i have to show list page view and another print page view in new tab from a single controller.

2. If user will click on "no" then i have to show list page view only from single controller.


Is it possible to show 2 different view from single controller on anchor button click with target blank.
Posted
Updated 2-Jul-15 6:02am
v3

Okay, after re-reviewing, I realize that this is a JavaScript-only solution.

HTML
<script type="text/javascript">
   var linkClicked = function(){
      var confirmed = window.confirm('Print?');
      if(confirmed){
         window.open('@Url.Action("PrintAction","Controller")','_blank');
      }
}
</script>


And the link:
C#
@Html.ActionLink("Click Me","Action","Controller,null,new { onclick="linkClicked()" }) 
 
Share this answer
 
v4
Comments
itsathere 2-Jul-15 10:18am    
You did not get the point i have written..Actually, I want to show 2 different view from same controller one for list page another target blank(new tab).
There is only one response so you can't send two views with one controller. The view you send to the browser will need to contain some javascript that opens the print-view page. It'll basically be what is in "Solution 2" only will just run as the page loads rather than on a click event.

XML
<script type="text/javascript">
    window.open( .... );
</script>


If you want it in a new tab you could put a form with the print page as the action, the method as GET and the target as "_blank" and submit the form via js rather than using window.open.
 
Share this answer
 
v2
I have already done it in partial view with the below code

C#
<a href="@Url.Action(" methodname=", " controllername=", new { id = Model.Id })" id="btnQRPrint" target="_blank"></a>



<script>
    var qr = jQuery.noConflict();
    qr(window).load(function () {
        debugger;
        var val = '@Html.Raw(TempData["ID"])';
        if (val > 0) {
            qr("#btnQRPrint")[0].click();
        }
    });
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900