Archive for November, 2009
VS 2008 File Finder with Wildcard Character Search
I’ve been working with Eclipse for almost too long. The Open Resource window has been a very convenient tool to me. After doing some quick googling, I’ve found that there’s a VS plugin written by Steve Huff that does almost the same thing as Eclipse’s Open Resource Window. It works very smooth and very easy to install! Please check out the official website here: http://www.huffs.us/blogEngine/page/VS-2008-File-Finder.aspx
The only one thing I also want in this File Finder plugin is the Wildcard Search function. So I’ve downloaded the code and made some simple adjustments.
The changes are made in the ProjectItemFinder.vb class:

The highlighted code was added by me. It’s for calling a new method which is similar to the existing MatchString function.

This new method WildcardMatchString simply uses the Like function to do wildcard character match.
Now VS 2008 File Finder now supports Wildcard search!!!

I would not post the new compiled plugin library here while I’m not the originally author. If you’d like to use File Finder with Wildcard Character Search like me, please download the source code from Steve Huff’s website and make the small modifications described above.
Escape and Unescape functions for Javascript and ASP.NET
I’ve been working on a chatroom application that requires some AJAX calls to submit messages from user input. Usually, when you want to pass string parameters into the web service, you may do something like this:

This jQuery script calls an asp.net web service method called submitMessage with two parameters sessionIdStr and messageText. The source of parameter messageText is from a input textbox. Since the user may enter any characters (including special characters), and if they have a single quote (‘) in their input, the above statement will break. To resolve this problem, we can simply make use of the escape and unescape functions from javascript.

The escape javascript function simply encode a string to remove all the special characters in order to ensure that messageText parameter is transmitted successfully within the ajax call. For more information about this function, click here.
Now that our messageText paramter can passed successfully to the web service, we may need to do an unscape operation within the web service method to revert it back to the original input. Microsoft has provided us with a very handy library in namescape Microsoft.JScript.GlobalObject.

Now we have the messageText parameter revert back to the original message. We may do our handling code accordingly.
Note that both Javascript and Micorosft.JScript.GlobalObject has escape and unscape operations, you may use the combination in the reverse way (within web service response).
This is it for this short tutorial. Recently, I’ve been dealing with the .NET System.Datetime and Javascript Date conversion, when I have sometime, I’ll share my experience with you here!