Wednesday, 30 March 2011

How we can open Popup Window using asp.net


Introduction
Though this article I will discuss how we can open popup window using anchor tag  in .aspx page.

HTML CODE

Paste this javascript function inside the <head> tag of .aspx page.
<head runat="server">
    <title></title>
<script type="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
// You can set the height width scrollbar & menubar according to your
// requirement
window.open(href, windowname, 'width=700,height=400,scrollbars=yes');
return false;
}
//-->
</SCRIPT>

</head>

Now see the body section of the .aspx page. I am calling the javascript function, which we have been created inside the head tag named popup()inside the <a>anchor tag.  For this see below


<body>
<form id="form1" runat="server">
    <div>
   <a  href ="http://useofaspdotnet.blogspot.com/"  onclick="return popup(this,'examplea')">this link</a>


    </div>
    </form>
</body>

See output below in popup window





5 comments:

  1. Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.
    SEO tools

    ReplyDelete
  2. Replies
    1. Hi!! jay suresh kumawat Thankx you sir. Please feel free to get in touch with my blog and you can also give us your expensive suggestions to improve this blog.

      Delete