MVC 3剃须刀弹出窗口 [英] MVC 3 Razor PopUp Window
问题描述
我需要在一个视图中点击一个按钮打开一个新的弹出窗口。新的窗口应该在特定的控制器被重定向到一个特定的actionmethod。我还需要为新的弹出窗口的大小提供属性。
我一直在尝试以下code:
I need to open a new pop up window on click of a button in a view. The new window should be redirect to a specific actionmethod in a specific controller. I also need to provide attributes for size of the new pop up window. I have been trying the following code:
<input type="button" name = "ClickMe" Value="ClickMe" onclick= "javascript:window.open('/Home/Create/','Customer Search',height='window.screen.height - 100', width='200',left='window.screen.width - 250' ,top='10',status='no',toobar='no',resizable='yes',scrollbars='yes')"/>
在点击按钮,没有任何反应。我得到下面的JavaScript错误:
On click of button, nothing happens. I get following Javascript error:
行:19结果
字符:1结果
错误:无效的参数。结果
code:0
Line: 19
Char: 1
Error: Invalid argument.
Code: 0
当我检查呈现的HTML的ViewSource,我觉得行是其渲染按钮之一。
我使用Windows Vista中的IE 7,我在VS 2010中工作的MVC 3剃须刀引擎
When I check the ViewSource of the HTML rendered, I find the line to be the one which is rendering the button. I am using Windows Vista with IE 7. I am working on MVC 3 with Razor Engine in VS 2010
推荐答案
尊重HTML。尊敬的JavaScript。尊重你正在写的框架,这已经完成了从第2版第3次到两个大的变化(验证和ajaxity)应用较新的,现代化的原则 - 的非侵入式JavaScript 。如果你遵循的原则(与VS的JavaScript synthax高亮的帮助下),你可以设法纠正在更短的时间错误你问的问题在这里度过的。
Respect html. Respect javascript. Respect the framework that you are writing on, that has made two big changes (validation and ajaxity) from its 2nd version to 3rd to apply the newer, modern principle - Unobtrusive Javascript. You could manage to correct that error in less time you spent on asking question in here if you followed that principle (with the help of vs javascript synthax highlighting).
<input type="button" id="ClickMe" name = "ClickMe" Value="ClickMe" />
...
<script type="text/javascript">
$(function () {
$('#ClickMe').click(function () {
window.open('/Home/Create/', 'CustomerSearch', 'height=' + (window.screen.height - 100) + ',width=200,left=' + (window.screen.width - 250) + ',top=10,status=no,toolbar=no,resizable=yes,scrollbars=yes');
});
});
</script>
和我发现,它与在IE窗口名称空间问题 - 客户搜索。如果删除的空间 - CustomerSearch',它会开始在IE工作太
And as I discovered, it's the issue with space in window name in IE - 'Customer Search'. If you remove that space - 'CustomerSearch', it'll start working in IE too
这篇关于MVC 3剃须刀弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!