mvc下,3种窗口弹出设置的方法 |
本文标签:mvc,窗口,弹出 1、通过重写,<input标签下按钮的onclick事件,来进行窗口的弹出设置: 复制代码 代码如下: <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=来获得窗口: 复制代码 代码如下: <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属性来重新返回框架窗口中,例如: 复制代码 代码如下: <%using (Html.BeginForm("EditGroup", "Admin", FormMethod.Post, new { target = "mainFrame" })) 这里是通过重写了beginform来实现的,在解析后代码和普通<form表单提交的形式是一样的 。 如果想在提交表单后在关闭小窗口,可以通过<input 中的onclick事件来控制,使用javascript::self.close();或者window.close();来控制 。 |