如何用C#在Asp.net中实现打开新网页而不关闭当前页
2012-02-23 10:53
691 查看
转自:/article/11410819.html
Tag:如何用C#在Asp.net中实现打开新网页而不关闭当前页
方法一:
Respose.Write("<script language='javascript'>window.open('"+ url +"');</script>");
(打开简洁窗口):
Respose.Write("<script language='javascript'>window.open('" + url + "','','resizable=1,scrollbars=0,status=1,menubar=no,toolbar=no,location=no, menu=no');</script>");
1.Response.Redirect("XXX.aspx",true)——直接转向新的页面,原窗口被代替;
2. Response.Write("<script>window.open('XXX.aspx','_blank')</script>")——原窗口保留,另外新增一个新页面;
3.Response.Write("<script>window.location='XXX.aspx'</script>")——打开新的页面,原窗口被代替;
4.Server.Transfer("XXX.aspx")——打开新的页面;
5.Response.Write("<script>window.showModelessDialog('XXX.aspx')</script>")——原窗口保留,以对话框形式打开新窗口;
6.Response.Write("<script>window.showModelDialog('XXX.aspx')</script>")——对话框形式打开新窗口,原窗口被代替;
Tag:ASP.NET打开新窗口的多种方法
ASP.NET打开新窗口方法一:
Response.Write("<script language=/"javascript/">window.open('aaa.aspx','新窗口,/"toolbar=yes,location=no,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes/");</script>");
这种方式代码每次是生成在页面最顶端
ASP.NET打开新窗口方法二:
string strScript = "";
strScript += "<script language=/"javascript/">/n";
strScript += "window.open('aaa.aspx','新窗口,/"toolbar=yes,location=no,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes/");/n";
strScript += "location.href='index.html';";
strScript += "</script>";
bool b = ((Page)System.Web.HttpContext.Current.Handler).IsStartupScriptRegistered("PopUp");
if (!b)
{
((Page)System.Web.HttpContext.Current.Handler).RegisterStartupScript("PopUp",strScript);
}
这种方式是在页面中生成JAVASCRIPT代码
注意:如果输出JAVSSCRIPT语句后,页面又用Response.Redirect跳转到其他页,JAVASCRIPT将不会出现.
实现弹出窗口和跳转同时必须都在JAVASCRIPT语句里,
这是我测试的,不知道大家有没有什么不同的意见??
asp.net中打开新窗口的多种方法
1.Response.Redirect("XXX.aspx",true)——直接转向新的页面,原窗口被代替;
2. Response.Write("<script>window.open(XXX.aspx'',''_blank'')</script>")——原窗口保留,另外新增一个新页面;
3.Response.Write("<script>window.location=XXX.aspx''</script>")——打开新的页面,原窗口被代替;
4.Server.Transfer("XXX.aspx")——打开新的页面;
5.Response.Write("<script>window.showModelessDialog(XXX.aspx'')</script>")——原窗口保留,以对话框形式打开新窗口;
6.Response.Write("<script>window.showModalDialog(XXX.aspx'')</script>")——对话框形式打开新窗口,原窗口被代替;
"_blank " Load the linked document into a new blank window. This window is not named.
"_parent " Load the linked document into the immediate parent of the document the link is in.
"_search " Load the linked document into the browser 's search pane. Available in Internet Explorer 5 or later.
"_self " Load the linked document into the same window the link was clicked in (the active window).
"_top " Load the linked document into the topmost window.
Tag:如何用C#在Asp.net中实现打开新网页而不关闭当前页
方法一:
Respose.Write("<script language='javascript'>window.open('"+ url +"');</script>");
(打开简洁窗口):
Respose.Write("<script language='javascript'>window.open('" + url + "','','resizable=1,scrollbars=0,status=1,menubar=no,toolbar=no,location=no, menu=no');</script>");
1.Response.Redirect("XXX.aspx",true)——直接转向新的页面,原窗口被代替;
2. Response.Write("<script>window.open('XXX.aspx','_blank')</script>")——原窗口保留,另外新增一个新页面;
3.Response.Write("<script>window.location='XXX.aspx'</script>")——打开新的页面,原窗口被代替;
4.Server.Transfer("XXX.aspx")——打开新的页面;
5.Response.Write("<script>window.showModelessDialog('XXX.aspx')</script>")——原窗口保留,以对话框形式打开新窗口;
6.Response.Write("<script>window.showModelDialog('XXX.aspx')</script>")——对话框形式打开新窗口,原窗口被代替;
Tag:ASP.NET打开新窗口的多种方法
ASP.NET打开新窗口方法一:
Response.Write("<script language=/"javascript/">window.open('aaa.aspx','新窗口,/"toolbar=yes,location=no,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes/");</script>");
这种方式代码每次是生成在页面最顶端
ASP.NET打开新窗口方法二:
string strScript = "";
strScript += "<script language=/"javascript/">/n";
strScript += "window.open('aaa.aspx','新窗口,/"toolbar=yes,location=no,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes/");/n";
strScript += "location.href='index.html';";
strScript += "</script>";
bool b = ((Page)System.Web.HttpContext.Current.Handler).IsStartupScriptRegistered("PopUp");
if (!b)
{
((Page)System.Web.HttpContext.Current.Handler).RegisterStartupScript("PopUp",strScript);
}
这种方式是在页面中生成JAVASCRIPT代码
注意:如果输出JAVSSCRIPT语句后,页面又用Response.Redirect跳转到其他页,JAVASCRIPT将不会出现.
实现弹出窗口和跳转同时必须都在JAVASCRIPT语句里,
这是我测试的,不知道大家有没有什么不同的意见??
asp.net中打开新窗口的多种方法
1.Response.Redirect("XXX.aspx",true)——直接转向新的页面,原窗口被代替;
2. Response.Write("<script>window.open(XXX.aspx'',''_blank'')</script>")——原窗口保留,另外新增一个新页面;
3.Response.Write("<script>window.location=XXX.aspx''</script>")——打开新的页面,原窗口被代替;
4.Server.Transfer("XXX.aspx")——打开新的页面;
5.Response.Write("<script>window.showModelessDialog(XXX.aspx'')</script>")——原窗口保留,以对话框形式打开新窗口;
6.Response.Write("<script>window.showModalDialog(XXX.aspx'')</script>")——对话框形式打开新窗口,原窗口被代替;
"_blank " Load the linked document into a new blank window. This window is not named.
"_parent " Load the linked document into the immediate parent of the document the link is in.
"_search " Load the linked document into the browser 's search pane. Available in Internet Explorer 5 or later.
"_self " Load the linked document into the same window the link was clicked in (the active window).
"_top " Load the linked document into the topmost window.
相关文章推荐
- 如何用C#在Asp.net中实现打开新网页而不关闭当前页
- 如何用C#在Asp.net中实现打开新网页而不关闭当前页
- 如何用C#在Asp.net中实现打开新网页而不关闭当前页
- 如何用C#在Asp.net中实现打开新网页而不关闭当前页
- 如何用C#在Asp.net中实现打开新网页而不关闭当前页
- :如何用C#在Asp.net中实现打开新网页而不关闭当前页
- sql server 关于表中只增标识问题 C# 实现自动化打开和关闭可执行文件(或 关闭停止与系统交互的可执行文件) ajaxfileupload插件上传图片功能,用MVC和aspx做后台各写了一个案例 将小写阿拉伯数字转换成大写的汉字, C# WinForm 中英文实现, 国际化实现的简单方法 ASP.NET Core 2 学习笔记(六)ASP.NET Core 2 学习笔记(三)
- 【C#】对异步请求处理程序IHttpAsyncHandler的理解和分享一个易用性封装 【手记】走近科学之为什么明明实现了IEnumerable<T>的类型却不能调用LINQ扩展方法 【手记】手机网页弹出层后屏蔽底层的滑动响应 【手记】ASP.NET提示“未能创建类型”处理 【Web】一个非常简单的移动web消息框 【手记】解决EXCEL跑SQL遇“查询无法运行或数据库表无法打开...”
- [ASP.NET教程] C#中如何实现数据拖动?(拖动图片,到TextBox,并显示)
- [转]在ASP.NET中如何用C#.NET实现基于表单的验证(二)
- ASP.Net、C#实现网页小偷程序
- C#.NET中怎样打开一个新Form,同时关闭当前Form?
- ASP.NET(C#)不提示直接关闭当前页面
- asp.net C#如何实现当地时区转换的代码实例
- c#中如何打开一个新窗口并且 关闭当前的窗口
- 在ASP.NET中如何用C#.NET实现基于表单的验证
- ASP.NET&C#学习笔录2(vs2010项目如何在vs2008中打开 )
- 在Asp.net中如何关闭网页,另外如何使文本框获得焦点
- [C#]使用 C# 代码实现拓扑排序 dotNet Core WEB程序使用 Nginx反向代理 C#里面获得应用程序的当前路径 关于Nginx设置端口号,在Asp.net 获取不到的,解决办法 .Net程序员 初学Ubuntu ,配置Nignix 夜深了,写了个JQuery的省市区三级级联效果
- 在ASP.net中,静态变量的生命周期是从服务器程序启动-到服务器程序关闭或被回收,而与你是否打开、关闭网页时无关的