Click here to Skip to main content
15,886,724 members
Articles / Web Development / HTML

Using AJAX and MDI on a web application

Rate me:
Please Sign up or sign in to vote.
4.66/5 (13 votes)
30 Jan 20073 min read 93.9K   1.8K   69  
This article talks about two “technologies”, AJAX technology and a multi windows environment (MDI) inside an Internet application
  • ajaxmdiweb_src.zip
    • AjaxMdiWeb_src
      • AjaxMDI.master
      • AjaxMDI.master.cs
      • AjaxMdiWeb_src .sln
      • AjaxMdiWeb_src .suo
      • App_Code
      • App_Data
        • ajaxmdi.mdf
      • Bin
        • AJAXExtensionsToolbox.dll
        • AJAXExtensionsToolbox.dll.refresh
        • Microsoft.Web.Preview.dll
        • Microsoft.Web.Preview.dll.refresh
        • System.Web.Extensions.Design.dll
        • System.Web.Extensions.dll
      • css
        • ajaxmdi.css
        • themes
          • alert.css
          • alert
            • bottom.gif
            • bottom_left.gif
            • bottom_right.gif
            • left.gif
            • overlay.png
            • progress.gif
            • right.gif
            • top.gif
            • top_left.gif
            • top_right.gif
          • alert_lite.css
          • alphacube.css
          • alphacube
            • bottom-left-c.gif
            • bottom-middle.gif
            • bottom-right-c.gif
            • button-close-focus.gif
            • button-max-focus.gif
            • button-min-focus.gif
            • frame-left.gif
            • frame-right.gif
            • left-top.gif
            • right-top.gif
            • top-middle.gif
          • darkX.css
          • darkX
            • button-close-focused.png
            • button-maximize-focused.png
            • button-minimize-focused.png
            • frame-bottom-left-focused.png
            • frame-bottom-mid-focused.png
            • frame-bottom-right-focused.png
            • frame-left-focused.png
            • frame-right-focused.png
            • titlebar-left-focused.png
            • titlebar-mid-focused.png
            • titlebar-right-focused.png
          • default.css
          • default
            • bottom_left.gif
            • bottom_mid.gif
            • bottom_right.gif
            • bottom_right_resize.gif
            • center_left.gif
            • center_right.gif
            • clear.gif
            • close.gif
            • inspect.gif
            • maximize.gif
            • minimize.gif
            • overlay.png
            • resize.gif
            • sizer.gif
            • top_left.gif
            • top_mid.gif
            • top_right.gif
          • mac_os_x.css
          • mac_os_x
            • B.png
            • B_Main.png
            • BL.png
            • BL_Main.png
            • BR.png
            • BR_Main.png
            • close.gif
            • L.png
            • L_Main.png
            • maximize.gif
            • minimize.gif
            • R.png
            • R_Main.png
            • T.png
            • T_Main.png
            • TL.png
            • TL_Main.png
            • TR.png
            • TR_Main.png
          • nuncio.css
          • nuncio
            • bottom_left.png
            • bottom_mid.png
            • bottom_right.png
            • center_left.png
            • center_right.png
            • close.png
            • minimize.png
            • overlay.png
            • top_left.png
            • top_mid.png
            • top_right.png
          • spread.css
          • spread
            • .gif
            • bottom-left-c.gif
            • bottom-middle.gif
            • bottom-right-c.gif
            • button-close-focus.gif
            • button-max-focus.gif
            • button-min-focus.gif
            • frame-left.gif
            • frame-right.gif
            • left-top.gif
            • right-top.gif
            • top-middle.gif
          • theme1.css
          • theme1
            • bottom_left.gif
            • bottom_mid.gif
            • bottom_right.gif
            • center_left.gif
            • center_right.gif
            • close.gif
            • maximize.gif
            • minimize.gif
            • sizer.gif
            • top_left.gif
            • top_mid.gif
            • top_right.gif
      • home.aspx
      • home.aspx.cs
      • images
        • btop.gif
        • cancel.gif
        • deleteColumn.gif
        • editColumn.gif
        • nb.gif
        • nbon.gif
        • progress.gif
        • saveColumn.gif
      • ModalDialog.aspx
      • ModalDialog.aspx.cs
      • Readme.txt
      • script
      • UserInfo.aspx
      • UserInfo.aspx.cs
      • UserMan.aspx
      • UserMan.aspx.cs
      • web.config
// Copyright (c) 2006 Sébastien Gruhier (http://xilinus.com, http://itseb.com)
// YOU MUST INCLUDE window.js BEFORE
//
// Object to store hide/show windows status in a cookie
// Just add at the end of your HTML file this javascript line: WindowStore.init()
WindowStore = {
  doSetCookie: false,
  cookieName: "__window_store__",
  expired: null,
  
  // Init function with two optional parameters
  // - cookieName (default = __window_store__)
  // - expiration date (default 3 years from now)
  init: function(cookieName, expired) {
    if (!cookieName)
      WindowStore.cookieName = cookieName;

    if (! expired) {
      var today = new Date();
      today.setYear(today.getYear()+1903);
      WindowStore.expired = today;
    }
    else
      WindowStore.expired = expired;

    // Create observer on show/hide events
    var myObserver = {
    	onShow: function(eventName, win) {
    	  WindowStore._saveCookie();
    	},
    	onHide: function(eventName, win) {
    	  WindowStore._saveCookie();
    	}
    }
    Windows.addObserver(myObserver);

    WindowStore._restoreWindows();
    WindowStore._saveCookie();
  },
  
  show: function(win) {
    eval("var cookie = " + WindowUtilities.getCookie(Windows.cookieName));
    if (cookie != null) {
      if (cookie[win.getId()])
        win.show();
    }
    else
      win.show();
  },

  // Function to store windows show/hide status in a cookie 
  _saveCookie: function() {
    if (!doSetCookie)
      return;
    
    var cookieValue = "{";
    Windows.windows.each(function(win) {
      if (cookieValue != "{")
        cookieValue += ","
      cookieValue += win.getId() + ": " + win.isVisible();
    });
    cookieValue += "}"
  
    WindowUtilities.setCookie(cookieValue, [WindowStore.cookieName, WindowStore.expired]);  
  },

  // Function to restore windows show/hide status from a cookie if exists
  _restoreWindows: function() {
    eval("var cookie = " + WindowUtilities.getCookie(Windows.cookieName));
    if (cookie != null) {
      doSetCookie = false;
      Windows.windows.each(function(win) {
        if (cookie[win.getId()])
          win.show();
      });
    }
    doSetCookie = true;
  }
}

// Object to set a close key an all windows
WindowCloseKey = {
  keyCode: Event.KEY_ESC,
  
  init: function(keyCode) {
    if (keyCode)
      WindowCloseKey.keyCode = keyCode;
    Event.observe(document, 'keydown', this._closeCurrentWindow.bindAsEventListener(this));
  },
  
  _closeCurrentWindow: function(event) {
    var e = event || window.event
  	var characterCode = e.which || e.keyCode;
  	var win = Windows.focusedWindow;
    if (characterCode == WindowCloseKey.keyCode && win) {
      if (win.cancelCallback) 
        Dialog.cancelCallback();      
      else if (win.okCallback) 
        Dialog.okCallback();
      else
        Windows.close(Windows.focusedWindow.getId());
    }
  }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Switzerland Switzerland
I am a C, C++ , C# and VB.NET software developer in Swiss. I actually work for SOPRA Group with C# and Oracle database.I have good experience in software development life cycle (analysis, requirements, design, coding, test and deploy). This experience spans many other experiences like embedded software, ATL, COM, Java application, complex Windows Installer Packages and more.
- 4+ years in .NET programming (especially C#);
- 3+ years in C/C++ programming;
- 3+ years in VB6, Java, Windows Installer

Comments and Discussions