April 18, 2008 by bwebster
I’ve used SQL to varying degrees for a number of years. However, one of the features I’ve recently learned about is the CASE statement. For some reason, I missed this powerful feature when I studied SQL.
When would you use the CASE statement? I use it when writing stored procedures when I want to have optional input parameters. Consider this simple stored procedure:
ALTER PROCEDURE [dbo].[GetRooms]
(
@roomID int = 0,
@color varchar = ”,
@type varchar =''
)
AS
BEGIN
SELECT roomID, roomName, roomColor, roomType, roomWidth, roomLength, roomheight
FROM tblRooms
WHERE
roomID = CASE @roomID WHEN 0 THEN roomID ELSE @roomID END
and roomColor = CASE @color WHEN '' THEN roomColor ELSE @color END
and roomType = CASE @type WHEN '' THEN roomType ELSE @type END
ORDER BY roomName
END
With this one Stored Procedure, we have a lot of options for what is returned, depending on what parameters we include in the call.
EXEC GetRooms - Returns all the rooms in the database.
EXEC GetRooms @roomID=3 - Returns the room with ID of 3
EXEC GetRooms @color=’blue’, @type=’kitchen’ - Returns all the kitchens that are blue
With the optional parameters, this one stored procedure can be used in a number of different scenarios. Using this technique, I once replaced about a dozen stored procedures in a database with just one. How cool is that!
Posted in Development, SQL, Stored Procedures, Uncategorized | 1 Comment »
April 16, 2008 by bwebster
On Monday, I received a call from an author of one of our county CMS pages. He was trying to upload a PowerPoint file, and the CMS was not accepting it. He was trying to upload a file that exceeded the 5MB per file limit. The primary reason for this limit is that most of the users of our web pages probably don’t want to wait for that big of file to download.
I suggested a few options that would allow this PowerPoint file to be uploaded. These included:
- Save it as a PDF file.
- Resize the photos used in the PowerPoint file
- Do a Save As…
- Split the file into part A and part B
About an hour later, I receive an email saying that he had resized the photos, then did a Save As to create a new PowerPoint file. The new file was 856KB, down from 6.5MB. This new file was easily uploaded into the CMS.
By doing a pretty simple process, he drastically reduced the file size, therefore making the file download a lot faster for the people that want to use this file. And the best part is, he did not have to compromise the quality of the presentation. Instead, he used photos that were appropriately sized for the way he was using them.
We typically tell people to do the resizing using Picture Manager. This is a utility that comes bundled with Office 2007. Here is a document that talks about how to use Picture Manager.
Although he was using a the photos in a PowerPoint file, the same principle also applies to web pages. Resize your photos before including them putting them on your web pages. The alternative is to set the display size in your HTML code, however, the browser still needs to download the whole image.
As a side note, we have been looking for a good solution to be able to dynamically resize images at runtime. We’d like to be able to upload the full image into the CMS, and have the CMS resize it when serving up the page. If you are doing this, I’d like to hear about it.
Posted in Design, Uncategorized | No Comments »
April 8, 2008 by bwebster
Recently, I added a Google Custom Search to our Program Builder web site. After this was in place for a couple months, the owners of the web site asked why certain pages weren’t showing up in searches.
Doing a little investigation, I discovered much of the information on the individual program pages was also on the summary page listing all the programs. Because of this duplication, Google was eliminating the individual programs from the search results.
The first thing I did to solve this was add a meta tag to tell robots not to index the summary page. I did this by adding this html code:
<meta name=“ROBOTS” content=“NOINDEX” />
While I knew I could allow the summary pages to drop off Google’s results pages without any intervention, it could take a while before Google noticed this change. Therefore, I went into the Google Webmasters Tools, and requested that the summary pages be removed from Google’s results.
The option to do this in under the “Tools” tab in the webmaster tools. You tell Google what URL(s) you want removed, and Google then makes sure you’ve done something to tell it to quit indexing the page(s), such as the above meta tag.
After about a day, the summary page dropped off Google’s search results, and the individual programs started appearing instead of the summary page. Mission accomplished.
More information on Google Webmaster Tools is available in this recording of a session I did for the eXtension Learn series. You can also access my Delicious bookmarks for this session.
Posted in Web2.0 | No Comments »
April 6, 2008 by bwebster
Kevin Gamble had an interesting post on this topic, “URLs and the dominance of search.” I’ve known for quite a while that search is extremely import. Web analytics on our web site have been telling us this.
However, Kevin’s post takes this to another level. I’ve never really thought of search terms as being a marketing tactic. It sounds like a great idea. In many cases, it would be a lot easier to remember a search term than it is to remember URL’s.
This will require web authors to work more on the search term(s) that users will use to access their sites. In my opinion, this is something that currently doesn’t get enough attention now, so maybe we can use this as another reason to get content providers to consider how they write.
Posted in Web2.0 | No Comments »
March 5, 2008 by bwebster
I keep forgetting where to find HtmlEncode when working in .NET. I end up going to Google and doing a couple searches before I find the right namespace to include. Hopefully now I’ll remember to look at my blog rather than Google
HtmlEncode does exactly what it sounds like it should. It takes a string value as a parameter, and returns an escaped string.
using System.Web;
private static string ReturnEncoded()
{
return (HttpUtility.HtmlEncode("<br />"));
}
This function would return “<br />”. Not a real useful function, but is shows how to use HtmlEncode.
This same location also has HtmlDecode, UrlEncode, and UrlDecode.
Posted in .NET, Development | No Comments »
February 24, 2008 by bwebster
The last few weekends, I’ve been able to spend quite a bit of time in the woodworking shop. This is a great get away for me.
On Saturday, I completed a mission style table for my living room. It is located by my front door, where I kick off my shoes. This area always looked messy, so I decided to try to fix that. Here is the result.

The inspiration for this table came from a table featured in WoodSmith magazine. I made some very major changes to those plans to make it better fit my needs.
A consideration in sizing this table was that it had to compliment this mirror, which I built last winter. It hangs behind the front door, and provides a place to hang coats.

The plans for this mirror came from an earlier issue of Woodsmith Magazine.
Now, I’m looking at the stand my TV is sitting on, and am thinking I see another upcoming project 
Posted in Fun, Personal, Woodworking | 7 Comments »
February 20, 2008 by bwebster
When doing a web application in .NET, I like to create a custom class that inherits from System.Web.UI.Page I usually call this class “MyWebPage”. In some (most) cases, this class doesn’t add any functionality, it’s just a wrapper. However, when you need to do certain things in your web app, this wrapper is invaluable.
When creating web forms, the first thing I do is change the code behind file, so it inherits from “MyWebPage” rather than default System.Web.UI.Page. This gives the new web form whatever functionality is built into “MyWebPage”.
When is this useful? Previously, I talked about dynamic master pages in a CMS application. By overwriting the PreInit method in “MyWebPage” to include the functionality for dynamic web pages, any new template that inherits “MyWebPage” will automatically receive this functionality. The alternative would be to override the PreInit method in every new template.
I first heard about making this page wrapper when Paul Sheriff gave a talk at an Iowa .Net User Group meeting. The example he gave was that you have a large .NET application. On Friday morning, your boss tells you that by Monday, the web application should log every time a page is hit, this log would be something above and beyond what the web server can log. Without the wrapper, you would have to edit every web form in the application, possibly hundreds of files. With the web forms inheriting from your wrapper class, you simply change this one class, and you enjoy the weekend.
Since then, I’ve heard this talked about on .NET Rocks, and also in this blog post by Brian Mishler.
Posted in .NET, Development, OOP | No Comments »
February 15, 2008 by bwebster
An important thing to remember about master pages is that you can have more than one in any given web application. For example, if some pages in your web application will be two columns, and some will be three, you might build two master files. Then, when you create the web forms, you select which master file to use.
A powerful use for multiple master pages in an application is to dynamically assign them when the page loads. Here is an example of code to do dynamic master pages. The example on this page is giving a different master page if the client is using a browser on Windows CE. The thing to remember about dynamically assigning master pages, is that it needs to be done very early in the page life cycle, in the PreInit method.
Imagine a situation where you want to host a web application for many different entities, for example, I recently watched a demonstration of a hosted 4-H enrollment application. Every state wants to have their own look to the application. An easy way to do this is by using dynamic master pages, and assigning them based on the username of the person that is logged in.
A place where we are using dynamic web pages extensively is in our Content Management Server (CMS). We have one set of templates that are used for 18 different sites. Each of these sites have their own branding and navigation, although many of them are similar. When we set up the sites in CMS, we set a custom property that tells it what master file to load. This allow us to provide a huge amount of customization by only modifying the two files that make up the master page. Our Midwest Grape and Wine Industry Institute site, and our Bioeconomy site are using this CMS application, and have quite different looks.
We are currently working on a project for community foundations, that will have a number of sites for individual community foundations. These sites will use the same CMS application as the ISU extension sites referenced above. However, they will have a completely different look and feel. This project was possible because we are dynamically assigning the master pages as the page loads.

Here are thumbnails of the three web sites referenced above that are using this single CMS application. The different looks is a result of the dynamic master pages mentioned above.
Posted in .NET, Development | 2 Comments »
February 14, 2008 by bwebster
One of the big improvements with .NET 2.0 is master pages. A master page is a template that you use to build the structure of your web pages. You use it to do things like branding, top navigation, side navigation, footer, etc. Anything that you want repeated on every page can be placed in a master page.
Before .NET 2.0, we would build things in user controls, and add the user controls to our pages. This worked reasonably well, until you wanted to add a new feature, such as a search box to all your pages. If you didn’t have a suitable user control on your pages, you’d create a new user control, then add that to every page in your web application.
With .NET 2.0 or later, you can add the search box to the master page, and every page using that master page will automagically get the search box. This can save a huge amount of time. I learned this a few weeks ago, when I had to modify project that was created in .NET 1.1.
On master pages, in addition to the branding and navigation elements, you provide one or more content ares. These content areas are where the individual pages are responsible for populating the content. However, the content page does not have to populate every content area, you can pick and choose which content areas to use. For example, if your master page has an area for a sidebar, but your page doesn’t have content for the sidebar, you simply leave that area off your content page. It is an error, however, when your pages implement a content area that is not on the master page.
SharePoint makes extensive use of master pages, so this is a concept I will continue working with and expanding my knowledge.
Posted in .NET, Design, Development, MOSS | No Comments »
January 23, 2008 by bwebster
Today, I read an interesting blog post titled “Make about:blank Your Homepage.” For the most part, I agree with what this article says, about:blank does make a good default homepage, especially in Internet Explorer. However, for about the last year, I’ve approached this a little differently in Firefox.
I use Firefox as my primary web browser. Currently I have Google set up as the homepage, but I don’t see this homepage unless I click on the Home button in the toolbar. Firefox has another option that allows you to have a homepage set up, and also a blank startup page when you open the browser.
To set this up:
- Select Tools–>Options…
- Make sure you’re on the Main tab
- Set your homepage to whatever you want
- In the dropdown list titled “When Firefox starts:”, select Open a blank page
That’s it. Now, when you open Firefox, it won’t waste time opening a homepage. You can proceed to whatever web site you want. You can click on the home button to go to the page you’ve configured as your home page.
I find this works extremely well for me, because I rarely go to the same page each time I open my browser.
Posted in tools | No Comments »