开发者

Popup window in .NET MVC

开发者 https://www.devze.com 2023-01-16 20:12 出处:网络
I have a requirement of populating a new开发者_如何学JAVA window (With no menus, no address bar) using the existing data that I have on the page.

I have a requirement of populating a new开发者_如何学JAVA window (With no menus, no address bar) using the existing data that I have on the page.

I am using a java script function for this purpose.

function popup() {
        window.open("../AcknowledgeStatements/OutStandingAckInPdf", '', 'scrollbars=yes,width=740,height=600,resizable=yes');
    }


<input name="cmdButton" id="cmdPrint" type="button" class="button" value="Print"  onclick="popup()"/>

How do I pass my Model and TempData/ViewData in this page to the popup window? Can someone help me on this?


Well since you don't want to see Menus or the Address bar, i would also add menubar=no,location=no to your optional specs arguments. You can find a full list of options here

Now, as far as passing data to your new window: window.open, doesn't have any way of doing this. What you would have to do is pass any data you want displayed on the popup to the server as GET arguments

function popup() {
    window.open("../AcknowledgeStatements/OutStandingAckInPdf?SomeParam=SomeValue&SecondParam=SomeValue", '', 'scrollbars=yes,width=740,height=600,resizable=yes');
}

then pass down your data in the view. But remmeber there are limitations on this as GET paramaters can limited in length to maximum length of a web address. This i think is 1024 char, but don't quote me on that.

Anyways, further more. Why do you need this data to show up in a popup. Popup windows a relic of the past that usually just annoy users. Most modern browsers tend to block popups and require a user to explicitly allows the popup to be displayed. You can save yourself a round trip to the server if you pre-include a template (good explanation behind what you can do with it) in your original html and then have it display as a dialog box. IMHO this is a much more friendly option then popups.

0

精彩评论

暂无评论...
验证码 换一张
取 消