Hi
I have an action link. When i click on that action link, it should open a new popup window with the size of 400px width and 400 px height. Now i gave the code like this.
@Html.ActionLink("Currently Loaded Data", "EqpmtCheckInfo", "Aircraft", new { Id = "ids" }, new { target="_blank", width = "400px", height = "400px" })
But this open in a new tab. I checked in Google chrome. I can do this with window.open() method. I need the exact like window.open(). Is it possible with @html.actionlink()?
Thanks
Bobbin
It’s not possible to do so,browser settings will fail your effort to do so.
IS there anyother method ….?
bobbin_sugarcrm
@Html.ActionLink("Currently Loaded Data", "EqpmtCheckInfo", "Aircraft", new { Id = "ids" }, new { target="_blank", width = "400px", height = "400px" })
try this
<a href="javascript:var x=window.open('about',target = '_blank', width = '400px', height = '400px');">Currently Loaded Data</a>
<a href='javascript:openwindow();'>Currently Loaded Data</a> <script> function openwindow() { var x=window.open('@Url.Content("~/Aircraft/EqpmtCheckInfo")',target = '_blank', width = '400px', height = '400px'); } </script>
Can we open partial view in window.open();
window need a url to open. you are opening partial view through a url (controller/action). so it is possible.
Hi bobbin,
Thanks for your post,
bobbin_sugarcrm
Can we open partial view in window.open();
As cnuonline mentioned,you can do it.
I did a simple sample,you can refer to the following code snippet according to your requirement and modify this:
The controller has a method to return the PartialView:
public PartialViewResult CreatePartialView() { return PartialView("MyPartialView"); }
The MyPartialView code looks like this:
<h1>Hello World</h1> <p> This is a very nice web page. </p>
Add a button to the Index page:
<input type="button" id="NewBrowserBtn" value="New Browser" />
and js:
$(document).ready(function () { $('#NewBrowserBtn').on('click', function () { window.open('/Home/CreatePartialView', '_blank', 'left=100,top=100,width=400,height=300,toolbar=1,resizable=0'); }); });
Notice the first parameter of window.open is the URL of the action method we added in the controller. You could easily pass a parameter by appending it to the URL.
Hope this can be helpful.
Best Regards,
Eileen