Internet Explorer z-index fix

Posted by Grubersauce

If you have an HTML element that you are showing and hiding you may have some problems in Internet Explorer.  IE decides to reorder your z-index depending on whether the elements are positioned relative based on some arbitrary context.  Whatever.  Here is a quick fix using jQuery:

$(document).ready(function() {
     // Following fixes IE z-index bug so tooltips can work
    var zIndexNumber = 1000;
    $('div').each(function() {
        $(this).css('zIndex', zIndexNumber);
        zIndexNumber -= 10;
    });
 
}); 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Posted on: 12/23/2009 at 3:51 AM
Tags: , , , ,
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (1) | Post RSSRSS comment feed

Using MVC with IIS 5.1

Posted by Grubersauce

If you're installing a website which uses Microsoft MVC for ASP.NET on a machine running IIS 5.1 (Windows XP), server requests without extensions explode.  The "fix" for this is setting a default (*) extension mapping to use ASP.NET.  We wrote a small .exe which we call from a custom action in InstallShield.

 
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.DirectoryServices;
using System.IO;
using System.Linq;
using System.Text;
 
namespace SetExtensionsForMVC
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                FileVersionInfo verinfo = null;
                if (File.Exists(@"C:\WINNT\system32\inetsrv\inetinfo.exe"))
                    verinfo = FileVersionInfo.GetVersionInfo(@"C:\WINNT\system32\inetsrv\inetinfo.exe");
                else if (File.Exists(@"C:\Windows\system32\inetsrv\inetinfo.exe"))
                    verinfo = FileVersionInfo.GetVersionInfo(@"C:\Windows\system32\inetsrv\inetinfo.exe");
 
                if (verinfo != null)
                {
                
                    Console.WriteLine("Major: " + verinfo.FileMajorPart);
                    Console.WriteLine("File version: " + verinfo.FileMinorPart);
 
                    if(verinfo.FileMajorPart == 5 && verinfo.FileMinorPart == 1 )
                    {
                        String ourApplication = args[0];
                        String strPath = "IIS://localhost/W3SVC/1/Root/" + ourApplication;
                        var iisEntry = new DirectoryEntry(strPath);
                        PropertyValueCollection applicationMappings = iisEntry.Properties["ScriptMaps"];
                        if (!applicationMappings.Contains(
                                 @"*,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1"))
                        {
                            Console.WriteLine("Writing extensionless mapping...");
                            applicationMappings.Add(@"*,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1");
                            iisEntry.CommitChanges();
                            Console.WriteLine("Complete!");
                        }
                        else
                        {
                            Console.WriteLine("Extensionless mapping already exists.");
                        }
                    }
                }
 
            }
            catch(Exception exception)
            {
                Console.WriteLine("An error occurred: " + exception.Message);
            }
        }
    }

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Posted on: 12/17/2009 at 7:09 AM
Tags: , , , , ,
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Modal Window Caching

Posted by Grubersauce

So you just implemented that neat new window fix to share the parent page's session... but it doesn't seem to update when data changes.  WTF mate?  Those modal windows love to cache.  Here's a quick fix:

 var linkURI = linkToOpen + "&random=" + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);

Appending an unused querystring parameter which is different each time (for the most part) will prevent the new page from loading from the cache.  I know this isn't a TRULY random number or guid, but it should do the trick.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Posted on: 12/3/2009 at 5:47 AM
Tags: , , , , , ,
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Popup Window Loses ASP.NET Session Variables

Posted by Grubersauce

In one of our apps, we have the ability to comsume our website through Windows Forms and open our website in a Windows WebBroswer control.  Everything works great until one of the links opens a new window for printing.  We were doing something similar to

window.open('someurl', ....);

The problem is, the new window loaded the page using content stored in our session variables.  The new window started a new instance of IE (or whatever the default browser is set to) and therefore created a new session for the page.  Scouring the Internets lists some ways to share the session via storing session in the database.  This just wasn't feasible for several reasons

  • The performance hit we take by storing variables in session rather than inproc
  • Having to mark all of those objects as serializable
  • A lot of work for something simple like getting the print button to work

The solution is to change how we are opening the new window to be a modal dialog

window.showModalDialog('someUrl', ....);

Using a modal dialog we still share the session with the parent page.  You may encounter some styling issues, but all in all, a lot better than changing where your session is stored and all the headaches involved in that.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5