Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
PopUp window using JavaScript in asp.net
WhatsApp
Purushottam Rathore
14y
66
k
0
0
25
Blog
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:
Figure: Popup window on Click 'Click Here' button.
Note: This will take some time because page will be load.
PopUp window using JavaScript in asp.net
Up Next
How To Use Session Value Client Side Using JavaScript In ASP.NET
Ebook Download
View all
ASP.NET MVC 5: A Beginner’s Guide
Read by 28.2k people
Download Now!
Learn
View all
Membership not found