- uniapp中怎么使用easycom 自定义组件
- uniapp使用@tap与@click的区别
- 门户型资讯类网站如何做SEO
- 网站源码中meta里面property="og:title"
- jQuery给动态添加的元素绑定事件的方法
- 微信小程序直播插件live-player-plugin使用
- 如何挽救百度降级的网站
- 图片轮显的代码
- 什么叫首选域?
- 移动终端浏览器初始设置apple-mobile-web-app-capable
邮箱:
手机:15383239821
.NET 中如何弹出新页面,而不出现阻止
一.用Response.Redirect()
比如在这个页面中有一个DropDownList 和 一个button ,dropdownlist 的value为一些页面的URL,当选好后,点击Button后,转向dropdownlist 的value对应的页面。
代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Button1.Attributes.Add("onclick","this.form.target = '_blank'");
}
protected void Button1_Click(object sender, EventArgs e)
{
string url = "http://www.baidu.com";
this.Response.Redirect(url);
}
}
二. 用Ajax实现
3、 问题搞清楚了事情也就好办了,我们可以用ajax来与服务器端通信,在客户端用javascript来编写事件处理程序,这样在客户端的就不会因为回传事件而重新加载页面,这样弹出窗口就不会被阻止了!
如:
Default.aspx:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>无标题页</title>
</head>
<script language ="javascript" >
function getAjaxXml()
{
var xml = new ActiveXObject("Microsoft.XMLHTTP");
var str="flag="+document.getElementByIdx("DropDownList1").value;
xml.open("GET","showxml.aspx?"+str,false); //get和post都可以
xml.send();
return xml.responseText;
}
function dropdownlistclick()
{
var value=getAjaxXml();
window.open (value);
}
</script>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" onchange="dropdownlistclick()">
<asp:ListItem Value="1.htm">1</asp:ListItem>
<asp:ListItem Value="2.htm">2</asp:ListItem>
<asp:ListItem Value="3.htm">3</asp:ListItem>
<asp:ListItem Value="4.htm">4</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
showxml.aspx.cs:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _showxml : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(Request ["flag"]);
}
}
- 上一篇:去除HTML代码的类
- 下一篇:ASP.NET伪静态的实现及伪静态的意义
-
2012-11-30CSS里面position:relative与position:absolute 区别
-
2023-11-17RESTful API 设计指南
-
2019-11-25dtcms常见问题
-
2010-07-20asp.net下实现URL重写伪静态之iis设置
-
2023-08-11提高微信关键词排名的十大技巧和策略
-
2012-06-30seo人员交流的知识
