To Avoid Popup Blocker to open Pop up from website.

The Following code will used to open popup window and the popup blocker will not block it.

Code Of The Parent Page of Popup

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopupBlocker.aspx.cs" Inherits="TestPopupBlocker" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" &gt;
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language ="javascript">
function getAjaxXml()
{
var xml;
if(document.all)
{
//IE
xml = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
//FF,Opera,NN
xml = new XMLHttpRequest();
}

var str="flag=888";
xml.open("GET","showXML.aspx?"+str,false);
xml.send(null); return xml.responseText;
}

function imgclick()
{
var value=getAjaxXml();
window.open ("http://www.asp.net/?xml="+value );
}
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="button" onclick="imgclick();"/>
</div>
</form>
</body>
</html>

Code Of The '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("xml" + Request["flag"]);
}
}

Comments

Popular posts from this blog

To Move items from one ListBox to another Listbox

Receive Json Web response in C#