Wednesday, 8 August 2012

JS : Fire Popup on Page_Load or any Click Event.

We can Call javascript from our Page.aspx as well as from our Codebehind of  Page.aspx.cs
Method #1:
you can simple write this Code:
 string popup = "<script language='javascript'>" + "window.open('YOUR-POPUP-PAGE.aspx','CustomPopUp', " + "'fullscreen=no,height=240,width=648,top=250,left=250,location=0,directories=0,status=no,scrollbars=no, dependant = no, alwaysRaised = yes, menubar=no,resizable=no')" + "</script>";
 ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "PopupScript", popup, false);
Method #2:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!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">
    <script>
        function popup() {
            window.open("Default.aspx");
        }
    </script>
</head>
<body onload="popup();">
    <form id="form1" runat="server">
    </form>
</body>
</html>


Good Luck`

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More