Skip to main content

So day 2 started with growing the control further, but first I wanted to set the code up to run in IIS.

Perl + IIS 7

First I created a simple application pool for this site to run in. One of the nice things is setting it to not run .NET Framework code, which just lowers your attack surface.

image

Next I created a simple web site to use that app pool, however there was no handler setup (odd, I thought ActivePerl’s install did this - but maybe it is IIS 6 only). To fix that I clicked on Handler Mappings

image

In there I added a Script Handler with the following settings:

image

Note I would leave Request Restrictions on the default UNLESS you have a good reason to do it.

After that brief config my Perl worked for a while, until I started getting this error (IIS Worker Process has stopped working) when browsing to the web page:

image

I had just changed code before that, so here is a quick test to you to try and find the fault. The snippet of Perl code looks like the following:

   1: print "<html> 
   2: <head> 
   3: <script src='jquery.js' type='text/javascript'></script>
   1:  
   2: <script src='jquery.simplemodal.js' type='text/javascript'>
   1: </script> 
   2: <script src='test.js' type='text/javascript'>
</script>
   4:  
   5: </head> 
   6: <body style='font-family: Calibri'> 
   7:  
   8: Username <input type='text' id='result' readonly='readonly'/><span id='test' style='color: #0000FF; text-decoration: underline; cursor: hand'>Select User</span> 
   9:  
  10: <div id='listContent' style='padding: 5px; background-color: #000000; color: #FFFFFF; border: thin solid #C0C0C0; width: 450px; overflow: scroll; height: 450px;'> 
  11: <div style='font-size: x-small; color: #C0C0C0; text-align: right; cursor: hand;padding-right: 20px;' class='simplemodal-close'>Cancel</div> 
  12: <span style='text-transform: capitalize; font-weight: bold; padding-bottom: 3px'>Select a user by clicking on their name</span> 
  13: <hr /> 
  14: Filter <input type="text" id="filter" /> 
  15: <hr />";

If you are stuck the here is a hint: Line 14.

.

.

.

Ok, if you got it good. If not, well it is because the HTML I was outputting had " in it and that caused the string to close and some garbage (from the compilers POV) to be after it. Why this has to kill the process I dunno, what’s wrong with a error message like we get from .NET?!

Filtering

I added a text box to the popup dialog so I could filter using JQuery .show and .hide methods. This is not that impressive but it did lead me to needing the jQuery documentation a lot (mainly for the selectors, but I also was getting weird results with hide… until I realized I had <br/> tags there and those weren’t getting hidden) and checking with the slow internet here was not great. So I found (read: I went to the jQuery Alternative Resources page) a cheat sheet I could print and stick on the wall in front of me. There are two listed there, one Excel and one Image. The image one looks nicer and is more verbose than the Excel one, but I went with the Excel one because it has examples… and I can figure out from the examples more than the verbose text in the image gives me.

One of the other things about filtering is that I wanted to be case insensitive, but I was using :contains to do the filtering which is case sensitive. I found a great thread on adding an extension method to it with a case insensitive version of :contains. I recommend if you are stuck copy/paste that one.