PopUp window using JavaScript in asp.net

Write the following JavaScript function on your page like as follows:

<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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 runat="server">
<title>PopUp Window</title>
<script type="text/javascript">
function popup(url) {
var width = 300;
var height = 200;
var left = (screen.width - width) / 2;
var top = (screen.height - height) / 2;
var params = 'width=' + width + ', height=' + height;
params +=
', top=' + top + ', left=' + left;
params +=
', toolbar=no';
params +=
', menubar=no';
params +=
', resizable=yes';
params +=
', directories=no';
params +=
', scrollbars=no';
params +=
', status=no';
params +=
', location=no';
newwin = window.open(url,
'd', params);
if (window.focus)
{
    newwin.focus()
}
return false;
}
</script>
</
head>
<
body>
<form id="form1" runat="server">
<div>
    <a href="javascript: void(0)" onclick="popup('http://www.c-sharpcorner.com')">Click Here</a> </div>
</form>
</
body>
</
html>

If you want to show some message or some content in popup window then you can give the xml file path like as follows:

<a href="javascript: void(0)" onclick="popup('XMLFile.xml')">Click Here</a>


Output:

popup.JPG
Figure: Popup window on Click 'Click Here' button.

Note: This will take some time because page will be load.