Joshua Stengel

Everything...Is going...
To be okay!
Getting paid enough?

30,055 participants contributed to the "A LIST APART" survey of people who are building the web (developers, designers, etc.).  Topics covered include things like, education, compensation, experience, age, ethnicity, vacation days, etc.

My favorite statistic, 13.8% of us have had a blog or personal site/blog for over a decade. 

What stood out to you?

Would you like a FREE book?

Help me spend my gift cards wisely and you can keep what I buy.

You pick them out. I buy them. I read them. I mail them to you--free of charge.

The rules are:

  1. The book(s) must be available from http://borders.com
  2. The book can be technical, fiction, audio, non-fiction, sci-fi, whatever, but it needs to be something I haven't read or don't already own.
  3. I will buy the most interesting recommendations first until my gift cards are spent, so sell me on why I should pick your recommendation.
  4. No reference books.
  5. Movies are okay, but picking a good movie that I haven't seen or don't own will be tough.
  6. If I pick your book, I'll email you to get your shipping info.  After I read your book, I'll send it to you or someone else on your behalf.
  7. USA delivery only.

Here are some things I might be interested in:

  • Books about successful businesses or business people
  • Interesting biographies
  • Comedies
  • New technical books

Tip! Get others to vote for your recommendation to improve your odds.

What the heck is the "Microsoft Web Platform Installer?"

In my TechNet Flash this morning I see this section:

Download the New Microsoft Web Platform Installer

The Microsoft Web Platform Installer lets you create a Web platform on your server. The Microsoft Web Platform is a reliable, high-performance Web stack that is capable of hosting both ASP.NET and PHP applications on a single server, and can scale to run the largest sites on the Web.

Question #1: "What is the Microsoft Web Platform?"
Question #2: "Why does it need an installer?"
Question #3: "How is it different that what I currently use to host my websites?"

So I did some reading...

Answer #1: The "Microsoft Web Platform" is nothing more than the collection of Microsoft products that might typically be installed on a web server (i.e., IIS, .NET Framework, SQL Server, VisualStudio, etc.).  It would be the equivalent of calling MS Office the "Microsoft Office Productivity Platform"--which I think is possibly how they (MS) will be referring to Office "12". 

Answer #2: The "Microsoft Web Platform Installer" is also kind of like the installer that comes with MS Office.  It allows you to selected the components you want to install, configure some settings, and carefully read through all the EULAs for the individual components before sitting back and enjoying a nice long progress bar.

Answer #3: Since you can "roll y'er own" Microsoft Web Platform by simply installing and configuring all the individual components manually, nothing is particularly special about the installer other than it is supposed to make it easier to setup a new web server.

In conclusion...

Dear Microsoft,

Thank you for providing us with fancy-smancy batch file. The fewer progress bars I have to look at the better.

However, "Boo...hiss", on the cheesy marketing description.

<rollingEyes>
The Microsoft Web Platform is a reliable, high-performance Web stack that is capable of hosting both ASP.NET and PHP applications on a single server, and can scale to run the largest sites on the Web.
</rollingEyes>

Sincerely,

Long-time "Microsoft Web Platform" Assembler

SEE ALSO:

"Just do it!", New Report Tells Government Execs about Web 2.0

In a recent report from the IBM Center for the Business of Government, government executives are strongly urged not to ignore the use of Web 2.0 technologies in their agencies and to re-think the way they serve the public.

The report is targeted at executive and management-level readers in the U.S. government and provides a nice outline of Web 2.0 technologies, how they are being used, and how the government can and should be leveraging them. Information is conveyed in a non-intimidating but firm manner using terminology and concepts common to the government world.

In my opinion, lacking from the report seems to be a good strategy for self-motivating the government to adopt Web 2.0 practices.  The government is not motivated by money in the same manner as businesses and therefore needs a realistic strategy for accepting risk as an acceptable part of innovation.

For much of the government, Evidence-Based Practice (EBP) is substantially the driving force. Unfortunately, acting only on ideas that provide evidence of a sufficient level of effectiveness creates a polarity with innovation. Therefore, what motivation does government have for adopting the always-beta, rapidly changing, and open elements found in Web 2.0?

Government, especially on a national level, typically has measures in place to determine how well it is serving its purpose. Feedback is the profit/loss performance indicator of the government world (at least in the USA). While politics and power-mongering are also forces in the system, as an ordinary citizen, feedback is how we help the government measure its customer service.

The next time you use a government service, don't just accept poor service as being "good enough for government work". If you see improvements in a government service, don't just be surprised and say nothing.  In a democracy, the government must hear from the public before it can respond.  We are not limited to a little booth on election days to talk to the government.  Every government survey, feedback form, comment card, and formal complaint is vote. Don't waste your opportunity to provide the government with the motivation they need to serve the public effectively.

Avoiding Duplication When Dynamically Adding Scripts and Styles to A Webpage

Recently, I had a project where I was wanting to be able to create a reusable UserControl to display tooltips throughout the application. The control would need to access the jQuery framework, a jQuery plugin, required some inline scripting, and had its own class of styles.  Not every page in the application would have tooltips but the pages that did use them would have a lot of them.

If I added all the references to the JavaScript and styles in the Master page, I would be introducing unnecessary bloat for the majority of the application.  So, I needed a way to request these resources in the UserControl so they would only be added to the page "on demand".

As you might image, adding them directly into the UserControl would mean that the resources would be requested for EVERY instance of the UserControl on the page.  If I used the control 10 times, the jQuery framework would get requested 10 times.  Not the most efficient design.

Fortunately, the .NET framework has a nice way of dealing with this by providing a way to dynamically add resources AND check to see if they are already loaded. 

Dynamically Adding JavaScript

If we just dynamically added links to script files, we would still have the same problem as adding them inline. So, here is a method that checks to see if the script has already been loaded and loads it only if needed:

   1: Protected Sub AddScriptFileToPage(ByVal ID As String, ByVal URL As String)
   2:     If Not Page.ClientScript.IsClientScriptIncludeRegistered(ID) Then
   3:         Page.ClientScript.RegisterClientScriptInclude(ID, URL)
   4:     End If
   5: End Sub

The one thing to note is that you need to provide some kind of ID for the script.  This ID is how .NET checks to see if the script has already been added to the page.  Personally, I think that using the filename of the JavaScript helps keep things consistent and kind of makes logical sense but it doesn't really matter as long as it will be unique to that resource.

If you need to add a block of inline JavaScript, no problem.  It's basically the same process with a tiny little tweak:

   1: Public Sub AddScriptBlockToPage(ByVal ID As String, ByVal Script As String)
   2:     If Not Page.ClientScript.IsClientScriptBlockRegistered(ID) Then
   3:         Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), ID, Script, True)
   4:     End If
   5: End Sub

 

Dynamically Adding Stylesheets

Though not as simple as adding scripts, we can do the same thing for our styles.  There are probably a number of way to do this but I chose to check the page header for an existing instance, and add a literal with the link to the stylesheet if it's not found.

   1: Public Sub AddCSSFileToPage(ByVal ID As String, ByVal URL As String)
   2:     If Page.Header.FindControl(ID) Is Nothing Then
   3:         Dim lit As New Literal()
   4:         lit.ID = ID
   5:         lit.Text = "<link rel=""Stylesheet"" type=""text/css"" href=""" & URL & """/>"
   6:         Page.Header.Controls.Add(lit)
   7:     End If
   8: End Sub

 

Making it Practical

You might be wondering why you would go through the trouble of doing all this. Lets make this a bit more useful by creating a class to help us use this functionality efficiently. I created a little ResourceLoader class in my application that looked something like this:

   1: Namespace Sample
   2:     Public Class ResourceLoader
   3:  
   4:         Public Shared Sub AddScriptFileToPage(ByVal ID As String, ByVal URL As String)
   5:             Dim p As Page = CType(System.Web.HttpContext.Current.Handler, Page)
   6:             If Not p.ClientScript.IsClientScriptIncludeRegistered(ID) Then
   7:                 p.ClientScript.RegisterClientScriptInclude(ID, URL)
   8:             End If
   9:         End Sub
  10:  
  11:         Public Shared Sub AddScriptBlockToPage(ByVal ID As String, ByVal Script As String)
  12:             Dim p As Page = CType(System.Web.HttpContext.Current.Handler, Page)
  13:             If Not p.ClientScript.IsClientScriptBlockRegistered(ID) Then
  14:                 p.ClientScript.RegisterClientScriptBlock(p.GetType(), ID, Script, True)
  15:             End If
  16:         End Sub
  17:  
  18:         Public Shared Sub AddCSSFileToPage(ByVal ID As String, ByVal URL As String)
  19:             Dim p As Page = CType(System.Web.HttpContext.Current.Handler, Page)
  20:             Dim lit As New Literal()
  21:             lit.ID = ID
  22:             lit.Text = "<link rel=""Stylesheet"" type=""text/css"" href=""" & URL & """/>"
  23:             If p.Header.FindControl(ID) Is Nothing Then
  24:                 p.Header.Controls.Add(lit)
  25:             End If
  26:         End Sub
  27:  
  28:     End Class
  29: End Namespace

Quick Note: In a class, you can't directly access the Page.  So, note how you can declare a Page and then use it in a class environment.

Now that we have this functionality in our application, we can efficiently request resources without having to worry about duplicating what has already been requested for the page.  For example, going back to my tooltip UserControl, here is how I could safely make sure that my resources are being requested but not duplicated:

   1: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   2:    Sample.ResourceLoader.AddScriptFileToPage("jQuery.js", "Script/jQuery.js")
   3:    Sample.ResourceLoader.AddScriptFileToPage("jQuery.ClueTip.js", "Scripts/jQuery.ClueTip.js")
   4:    Sample.ResourceLoader.AddScriptBlockToPage("Tooltip.ascx", "$(document).ready(function() {$('a.Tooltip').cluetip({splitTitle: '|'},{cursor: 'pointer'});});)")
   5:    Sample.ResourceLoader.AddCSSFileToPage("jQuery.ClueTip.css", "CSS/jQuery.ClueTip.css")
   6: End Sub

Notice that every instance of the control will make sure that the jQuery framework, the plugin, the inline script, and the custom styles are loaded but, thanks to our handy-dandy ResourceLoader class, no duplication will take place.

 

Final Thoughts

Even though we aren't duplicating resource requests, we are adding more objects to the page and this potentially introduces latency issues.  It also introduces the opportunity to look at how we might extend this technique to combine everything before page makes the request.  I've been reading a few ideas on how this might done and, if I end up with a good solution, I'll write a follow up.

If you have any ideas, comments, criticisms, or suggestions please share.

Posted: Aug 01 2008, 05:23 PM by jstengel | with 1 comment(s)
Filed under: , ,
UserAgent Fix for the RSSToolkit 2.0.0.0

I frequently use the RSSToolkit to consume and display RSS feeds from other blogs.  Recently, I've noticed problems with the RSSToolkit not being able to display feed from some external sources.  In particular, I've been having trouble consuming feeds from external blogs like Blogspot and Feedburner.  The symptoms appeared over the past month or two and included the disappearance of consumed blogs and new blog posts.

After some digging, I found this entry on Obishan's blog that gave me a clue. Using Web-Sniffer, I was able to verify that if no UserAgent was provided for the request, the request was redirected (302).  This redirection seems to the source of my problems with the RSSToolkit and I'm not the only one.

This wasn't my first crack at fixing an issue with the RSSToolkit, so I spent some time tracking done how to fix this issue. Basically, I needed to find out where the RSSToolkit was actually requesting the RSS and find out how to modify the request so that it included a UserAgent. In my fix I am hardcoding in the UserAgent.  Ideally, this would be set through a property in the control.

The Fix

Step 1: Download the Source

Step 2: Update the Code

Open RSSToolkit > RSS > DownloadManager.cs and replace the DownloadFeedDom() with the following:

private CacheInfo DownLoadFeedDom(string url)
        {
            //// look for disk cache first
            CacheInfo dom = TryLoadFromDisk(url);

            if (CacheReadable(dom))
            {
                return dom;
            }

            string ttlString = null;

            //MODIFICATION: Some RSS sources like Facebook and Feedburner look
            //for a UserAgent (browser/OS information)

            String userAgent = @"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
            HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url);
            httpRequest.UserAgent = userAgent;
            HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
            XmlDocument doc = new XmlDocument();
            doc.Load(httpResponse.GetResponseStream());
            httpResponse.Close();
            doc.Save(Console.Out);

            //END OF MODIFICATION

            if (doc.SelectSingleNode("/rss/channel/ttl") != null)
            {
                ttlString = doc.SelectSingleNode("/rss/channel/ttl").Value;
            }

            //// compute expiry
            int ttlMinutes = GetTtlFromString(ttlString, _defaultTtlMinutes);
            DateTime utcExpiry = DateTime.UtcNow.AddMinutes(ttlMinutes);

            //// save to disk
            return TrySaveToDisk(doc, url, utcExpiry);
        }

Step 3: Rebuild the Project and use the new RssToolkit.dll

(Optional) Step 4: Download my copies.  My versions also include my fix for Atom feeds.

Sorry, Vista...It's not you, it's me.

I bought a discount PC from a highly reputable company (okay, it was Woot) a couple of months ago to replace my aging PC at home.  I come from a hardware background so I'm more apt to put up with crappier parts in exchange for a good deal.  However, when "crappy" meets "incompatible", I've got problems.

Problem #1:

My new PC came with a dual-head PCIe video card.  Cool, I thought.  I can just slap my extra PCI video card in the free slot and my 3-monitor setup will just as good as under my older Windows XP machine with the single onboard AGP and added dual-head PCI setup. WRONG! WRONG! WRONG!

Windows Vista is picky about the co-interminglicizing of video cards when using PCI Express.  Long story short, don't try it.  Either use the same video cards from the same vendor in the same adapter friendly, or prepare for a battle you will lose.

Problem #2

So, it won't work under Vista. Okay, I need 3 monitors more than a pretty-but-bitchy OS (yeah, you know what I mean).  I'll just go back to XP on my new machine.  NOPE!

Turns out XP doesn't like the chipset in my motherboard and blue screens during setup.  Long story short, XP setup does not have the necessary mass storage drivers to get through the setup.  Why not load the drivers on a disk and use the F6 method? Well, this system does not have floppy disk support.  So, I thought I would be clever and try to slipstream the drivers into a custom XP setup disk.  It may have been clever, but it still didn't work.

Bottom Line

I'm pretty much hosed.  It's back to my old system that, even though it's not as wizz-diddly as the new one, is still more functional that my new Vista PC that won't run XP.

Moral of the Story

I don't know that there is much to learn here.  I guess for a few hundred bucks (cost of the new PC) I learned a lot about about Vista's support for multiple graphics adapters and also how to use slipstreaming to create custom OS setup disks.  I also leaned to love the word "slipstream" and plan to use it as often as possible.

Anyone else want a learning experience? 

For Sale: One (1) slightly used PC.

Bonus Material

Did you know that "slipstream" can also be defined as "the "burble" of turbulence generated by an object passing through air or space, as the airstream or backwash (wash) around an aircraft from its propulsion?" Awesome! In true tech-style lingo, I give you "BUTT", the newest buzzword for the latest development process designed to intimidate and impress those who are just too stupid to grasp the advantages of having more BUTT action in their environment.


"Burble"-Up Transfer of Technology (BUTT)
The process of slipstreaming lessons learned from past projects into future projects.

Problem: Existing users will try to create new accounts

A typical web-based authentication system will have two options--Sign In (a path for existing users) and Register (a path for new users).  Potential problems for users arise when they don't know if they have an account, or they have tried to sign in unsuccessfully and decide to try to create another account.  Typically, when an existing user tries to create another account, they get an error message or some instructions for recovering their information.  The user may or may not bother with the effort.

Consider this...How likely is it that an existing user, when trying to create a new account, will use the same or similar information as when they first created their account? Now, imagine if you simply allowed the registration form to also act as a sign in form. Or, make the sign in form step one of the registration process.  It should be easy attempt an authentication using the information in a registration form and bypass the actual creation of a new account if an existing account is found, so why not do it?

I know what you're thinking...what if the user *doesn't* enter the same information.  For example, what if the username is different but the provided email address matches an existing account.  Create a trigger that starts the necessary account recovery process and notify the user what is happening?

By allowing authentication to happen in a registration form you can potentially:

  • Unobtrusively sign in existing users who didn't know they had an account.
  • Save user frustration by triggering the login recovery process for them using information they already provided.
  • Prevent abandonment by users not willing to make the traditional effort.

What do you think?  Anyone doing this or considering this approach? Why/why not?

Un-sucking the Radio Button

I swear radio buttons pucker up the closer my mouse gets to them.  Aside from the lack of good CSS options for radio buttons, they demand a certain level of commitment from the user. Unlike our promiscuous friend the checkbox, once you manage to jab the tip of your mouse into the pinhole of a radio button that's it. There's no unpoking that hole. Sure, you might be able to move it around in a group of radio buttons but, you're pretty much committed to an option.

So, to un-suck the radio button, we need:

  • Free will.  The users should be able to unselect their answer.
  • Mutual exclusiveness.  If we don't have this, we've got nothing but checkboxes.  Only one answer can be selected.
  • Potential beauty: Why be limited to puckered pinholes if we can pretty it up a bit.

By creating a little mash-up using some controls from the AJAX Control Toolkit, maybe we can make something a little better than the standard HTML inputs.  Let's be honest.  This is not a lightweight approach.  I'm not going to tell you what to do but, I would only do this only where the UI bang is worth the page load buck.Don't click on this.  It's just a screenshot.

Let's tackle mutual exclusiveness first. In case you aren't familiar with the terminology, mutual exclusiveness is the idea that by selecting one item, you exclude yourself from selecting something else. For example, if you chose life, you cannot choose death.  To chose death you must not choose life.  So, how do we assure a monogamous answer using a bunch of promiscuous checkboxes? For this task, we'll need a chaperone and, fortunately, the Toolkit also has a little thing called a MutuallyExclusiveCheckBoxExtender--just rolls off the tongue doesn't it.   This control can make check boxes behave like radio buttons! Yes! No, wait...radio buttons suck, right? A square pinhole is really not that much more fun to poke than a round one, is it?

Enter the ToggleButtonExtender.  This AJAX Control Toolkit control allows you override the default HTML checkbox with your own custom images.  Sweet! If we use this with some checkboxes, we have achieved "free will" and "potential beauty" in one shot.

By combining a couple of ready-made tools, we can un-suck the radio button by using checkboxes.  Hmmm...Maybe I should have titled the article "Checkbox Performance-Enhancing Controls". It doesn't really matter.  The goal is to create a better user interface for a task and that's what un-sucking is all about.

 

Reality Check!

Why NOT to do this:

  • The complexity and page size increases exponentially the more options you add so, use wisely.
  • You are a Javascript wizard and don't want to add the Toolkit's baggage.
  • Getting the selected value for the pseudo-RadioButtonList and validation is trickier. So what? You're a great programmer and can handle it, right?
  • It makes it easier for users to see what is selected and not selected.  So, if you rely on users not seeing which puckered pinhole they may or may not have selected, don't do this.
Flash/AJAX File Upload w/ Progress Server Control

Editor Note: This control does not support the most recent release of Adobe Flash.  Certain security updates from that release prevent the control from working.  Since the release of this control, others have released similar controls that are compatible and I would encourage you to explore those options.  

Recently, I blogged about my favorite file upload technique for web applications--the free flash/JavaScript-based SWFUpload.  While this library is not the perfect solution for all circumstances, it certainly provides a very nice user experience and is worth seeing if it matches your project's requirements.

I have a project I'm working on that needs a graceful file upload process. The environment is compatible with the flash/JavaScript requirements so I made myself a .NET control for the library.  The control contains all the necessary JavaScript and you can set the properties (allowed file types, file size, etc.) just like a normal control so you don't have to mess with any of the scripting. 

The features of this control include:

  • Multiple file upload (queuing)
  • Upload progress indicator
  • Ability to cancel queued files
  • NO visible PostBack (uses AJAX)

For those of you who may be wondering if you just stumbled onto the the "holy grail" of file uploads here, hold y'er horses...

This is my first customer server control ever. I'd never made one before and this was my "learning project".  It's probably not a highly tested and production-ready control. That said, you have the source and it's not that complicated so maybe you can customize it or clean it up if necessary. I would like to know what you think--good or bad, so let me know if you find problems or have some ideas to share.

More Posts Next page »