This project is read-only.

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

Working DEMO http://www.webinfocentral.com
(Select Menu Item 'TECH', then 'MOTOSPORT')

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);
    }
}

 

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 Feb 18, 2015 at 2:48 AM by DrABELL, version 11