Pop-ups in ASP.NET


Introduction

Pop-up ads or pop-ups are a form of online advertising on the World Wide Web intended to attract web traffic or capture email addresses. Pop-ups are generally new web browser windows to display advertisements. The pop-up window containing an advertisement is usually generated by JavaScript, but can be generated by other means as well.

Considerations

There are lots of points to be considered while working with pop-ups.

The syntax of the window.open method is given below:

window.open (%u201CURL%u201D, %u201CwindowName%u201D, %u201C[windowFeatures]%u201D)

URL:Which page to open. If external then use : http://www.google.com If internal then use
foldername/filename.aspx
OR
filename.aspx

windowName: Name of window. window features: It includes the different features like
Property Name   Description
***************************************************************
status          The status bar at the bottom of the window.
toolbar         The standard browser toolbar, with buttons
                such as Back and Forward.
location        The location entry field where we enter the URL.
menubar         The menu bar of the window.
directories     The standard browser directory buttons.
resizable       Allow/Disallow the user to resize the window.
scrollbars      Enable the scrollbars if the document is bigger
                than the window.
height          Specifies the height of the window in pixel.
width           Specifies the width of the window in pixel.


Default.aspx page:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" 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>Pop-ups in ASP.Net</title>
</head>


<body onload="javascript: poponload()" onunload="javascript: onunload()">
    <form id="form1" runat="server">
    <div>
    <!-- Script Coding (can be anywhere in body)-->
    <script language="javascript">
    function poponload()
    {
    testwindow= window.open ("http://www.google.com", "mywindow",

    "location=1,status=1,scrollbars=1,width=400,height=400");
    }
    function onunload()
    {
    testwindow= window.open ("add1.aspx", "mywindow",

     "location=1,status=1,scrollbars=1,width=450,height=500");
    }
    </script>
    <!-- Script Coding Closing (can be anywhere in body)-->


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

Comments

Popular posts from this blog

Customize User's Profile in ASP.NET Identity System

Lambda two tables and three tables inner join code samples