想做页面美化,特别是在一个页面中,只占了很小一块的页面,想做成弹出窗口样式,稍微总结了下:

1、通过重写,<input标签下按钮的onclick事件,来进行窗口的弹出设置:

 

 
  
  1. <input type="button" onclick="window.open('../AddDpment','','height=180,width=550,fullscreen=no,resizable=yes,scrollbars=no,top=350,left=500')" value="添加部门"/> 

其中,window.open('路径','窗口的宽度,高度,相对窗体的位置,是否全屏,是否有滑动等属性设置','','');

2、通过重写<a herf=''来获得窗口:

 
  
  1. <a href="" onclick="window.open('<%=Url.Action("EditDpment","Admin",new{id = item.Department_id}) %>','','width=530,height=200,location=no,menubar=no,status=no,scrollbars=no,resizable=no top=300,left=500')">部门修改</a><br /> 

其中。由于MVC中,路径的原因,这里推荐使用<%=url.action>来设置其路径,这里可以通过url.action中创建new{id}来传参数。

3、可以通过jquery来定义,并在控件中调用

弹出窗口后,可以通过重新定义表单的地址和target属性来重新返回框架窗口中,例如:

 
  
  1. <%using (Html.BeginForm("EditGroup", "Admin", FormMethod.Post, new { target = "mainFrame" })) 

这里是通过重写了beginform来实现的,在解析后代码和普通<form表单提交的形式是一样的。

如果想在提交表单后在关闭小窗口,可以通过<input 中的onclick事件来控制,使用javascript::self.close();或者window.close();来控制。