.NET MVC 中的弹出窗口
我需要使用页面上的现有数据填充一个新窗口(没有菜单,没有地址栏)。
我正在使用 java 脚本函数来实现此目的。
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()"/>
如何将此页面中的模型和 TempData/ViewData 传递到弹出窗口? 有人可以帮我解决这个问题吗?
I have a requirement of populating a new 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,既然您不想看到菜单或地址栏,我还会将 menubar=no,location=no 添加到您的可选规格参数中。您可以在此处找到完整的选项列表。
现在,就将数据传递给新的window: window.open,没有任何方法可以做到这一点。您需要做的是将想要在弹出窗口上显示的任何数据作为 GET 参数传递到服务器,
然后在视图中传递数据。但请记住,这方面存在限制,因为 GET 参数的长度可以限制为网址的最大长度。我认为这是 1024 个字符,但不要引用我的话。
无论如何,还有更多。为什么需要这些数据显示在弹出窗口中。弹出窗口是过去的遗物,通常只会惹恼用户。大多数现代浏览器倾向于阻止弹出窗口并要求用户明确允许显示弹出窗口。如果您预先包含 模板(很好地解释了你可以用它做什么)在你的原始html中,然后让它显示为 对话框。恕我直言,这是一个比弹出窗口更友好的选项。
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
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.