Search
Project Description
Use Javascript Window.Open function to set ASP.NET web page attributes and make it look "window application-like"

Working DEMO http://www.webinfocentral.com/RESOURCES/Motosport.aspx (Click on "Big Map" button to open a full-screen Interactive NASCAR Map)
MORE READING ON RIA (HTML 5, CSS 3, jQuery):
  1. HTML 5, CSS 3 and Inflation Calculator
  2. Rich internet applications, part 1: embedding YouTube™ video player into web page
  3. Rich internet applications, part 2: Silverlight™ media player
  4. Rich internet applications, part 3: HTML 5 video player
Browser Compatibility: IE 6.0/7.0/8.0+, FireFox 2.0/3.0, Safari/Chrome

Project contains:
1. C# Module (InfosoftOpenWindowJS.cs)
2. Sample ASP.NET DEMO Web page (Default.aspx with corresponding code behind Default.aspx.cs) to demonstrate the functionality
C# Code module to be placed in App_Code directory
//******************************************************************************
// Module           :   InfosoftOpenWindowJS.cs
// Author           :   Alexander Bell
// Copyright        :   2007-2009 Alexander Bell
// Date Created     :   02/15/2007
// Last Modified    :   09/29/2009
// Description      :   Open Web Page and set Window attributes using Javascript

//******************************************************************************
// DISCLAIMER: This Application is provide on AS IS basis without any warranty
//******************************************************************************

//******************************************************************************
// TERMS OF USE     :   This module is copyrighted.
//                  :   You can use it at your sole risk provided that you keep
//                  :   the original copyright note.
//******************************************************************************

using System;
using System.Web;

///*****************************************************************************
/// <summary>Open Web page and set Window attributes using Javascript</summary> 
public static class OpenWindowJS
{
    #region Open Full Screen Window
    /// <summary>Open Browser Window: Full Screen</summary>
    /// <param name="URL">string</param>
    /// <param name="Name">string</param>
    /// <param name="FullScreen">bool</param>
    /// <param name="MenuBar">bool</param>
    /// <param name="Resizable">bool</param>
    /// <param name="Toolbar">bool</param>
    /// <param name="Location">bool</param>
    /// <param name="StatusBar">bool</param>
    /// <param name="Copyhistory">bool</param>
    /// <param name="ScrollBalr">bool</param>
    /// <returns>string</returns>
    public static string GetScript
       (string URL, 
        string Name, 
        bool FullScreen, 
        bool MenuBar,
        bool Resizable,
        bool Toolbar,
        bool Location,
        bool StatusBar,
        bool Copyhistory,
        bool ScrollBar)
    {
      string ret = "javascript:void window.open ('";
      ret = ret + URL + "', '" + Name + "', '";
      ret = ret + "fullScreen=" + ((FullScreen) ? "1" : "0") + ",";
      ret = ret + "resizable=" + ((Resizable) ? "1" : "0") + ","; 
      ret = ret + "menuBar=" + ((MenuBar) ? "1" : "0") + ",";
      ret = ret + "toolbar=" + ((Toolbar) ? "1" : "0") + ",";
      ret = ret + "location=" + ((Location) ? "1" : "0") + ",";
      ret = ret + "statusBar=" + ((StatusBar) ? "1" : "0") + ",";
      ret = ret + "copyhistory=" + ((Copyhistory) ? "1" : "0") + ",";
      ret = ret + "scrollBar=" + ((ScrollBar) ? "1" : "0") + ",";
      ret = ret +  "')";
      return ret;
    }
    #endregion

    #region Open Window with adjustable Width/Height
    /// <summary>Open Browser Window, set Width/Height</summary>
    /// <param name="URL">string</param>
    /// <param name="Name">string</param>
    /// <param name="Width">string</param>
    /// <param name="Height">string</param>
    /// <param name="MenuBar">bool</param>
    /// <param name="Toolbar">bool</param>
    /// <param name="Location">bool</param>
    /// <param name="StatusBar">bool</param>
    /// <param name="Copyhistory">bool</param>
    /// <param name="ScrollBar">bool</param>
    /// <returns>string</returns>
    public static string GetScript
       (string URL,
        string Name,
        string Width,
        string Height,
        bool MenuBar, 
        bool Toolbar,
        bool Location,
        bool StatusBar,
        bool Copyhistory,
        bool ScrollBar)
    {
        string ret = "javascript:void window.open ('";
        ret = ret + URL + "', '" + Name + "', '";
        
        ret = ret + "resizable=1,";
        ret = ret + "width=" + Width + ","; 
        ret = ret + "height=" + Height + ",";

        ret = ret + "menuBar=" + ((MenuBar) ? "1" : "0") + ",";
        ret = ret + "toolbar=" + ((Toolbar) ? "1" : "0") + ",";
        ret = ret + "location=" + ((Location) ? "1" : "0") + ",";
        ret = ret + "statusBar=" + ((StatusBar) ? "1" : "0") + ",";
        ret = ret + "copyhistory=" + ((Copyhistory) ? "1" : "0") + ",";
        ret = ret + "scrollBar=" + ((ScrollBar) ? "1" : "0") + ",";
        ret = ret + "')";
        return ret;
    }
    #endregion
}
///*****************************************************************************************
Demo Web Page
<%@ 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>OPEN NASCAR MAP | DEMO</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" Text="OPEN NASCAR MAP: FULL SCREEN" />
            <br />
            <asp:Button ID="Button2" runat="server" Text="OPEN NASCAR MAP: 800/600" />
        </div>
        </form>
    </body>
</html>
Code behind page
//******************************************************************************
// Module           :   Default.aspx.cs
// Author           :   Alexander Bell
// Copyright        :   2007-2009 Alexander Bell
// Date Created     :   02/15/2007
// Last Modified    :   10/04/2009
// Description      :   code behind (ASP.NET)

//******************************************************************************
// DISCLAIMER: This Application is provide on AS IS basis without any warranty
//******************************************************************************

//******************************************************************************
// TERMS OF USE     :   This module is copyrighted.
//                  :   You can use it at your sole risk provided that you keep
//                  :   the original copyright note.
//******************************************************************************
using System;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // set target URL
        string _URL = "http://www.webinfocentral.com/_RESOURCES/NascarMap.aspx";
        
        // get Javascript to open full screen browser window
        string _scriptJS1 =
        OpenWindowJS.GetScript(_URL, "NascarMap", true, false, false, false, false, false, false, false);

        // get Javascript to open web page with predfined size (800x600)
        string _scriptJS2 =
        OpenWindowJS.GetScript(_URL,"NascarMap1", "800", "600", false,false,false,false,false,false);

        // add script to onclick event of page control
        Button1.Attributes.Add("onclick", _scriptJS1);

        // add script to onclick event of page control
        Button2.Attributes.Add("onclick", _scriptJS2);
    }
}
Other online projects by Dr. Alexander Bell

Web Javascript ASP.NET ASP.NET 2.0 ASP.NET 3.5 HTML IE FireFox Safari Chrome Window.Open Full Screen Bing NASCAR Motosport Geocoder
Last edited Nov 15 2010 at 10:23 PM by DrABELL, version 8
Updating...
© 2006-2012 Microsoft | Get Help | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2012.1.11.18365