•
I’ll make no bones about it, VS08 SP1’s Javascript Intellisense saves me from having to dive into the docs every five seconds. Not having that fingertip intelligence to my hand would probably cost me quite a bit of time each day. However, since I often end up using multiple frameworks in one project, I tend to use the jQuery.noConflict(); to avoid it conflicting with the other frameworks. Unfortunately, the moment you stick var $j = jQuery.noConflict(); into the top of your javascript file, your intellisense will break for the rest of your script. I’ve currently got two methods for handling this:
1 – Create a “preload” file
This is a small script that sits in between loading jQuery and loading your page scripts. All it contains is the following statement:
var $j = jQuery.noConflict();
Save it as preload.js and you can then sandwich this in between loading the jQuery framework and loading the page scripts as so:
<head>
<script type="text/javascript" src="scripts/jquery-1.3.2.js"></script>
<script type="text/javascript" src="scripts/preload.js"></script>
<script type="text/javascript" src="scripts/whatever-you-want.js"></script>
</head>
In your actual work scripts, you can then reference jQuery and the preload using the standard VS reference notation:
/// <reference path="jquery-1.3.2.js" />
/// <reference path="preload.js" />
Visual studio will have sorted out it’s type resolution for $j meaning that so long as you also have the jQuery .vsdoc file in the same folder as jQuery you get this glorious view:

The pros of this technique are that you can drop in new versions of jQuery at a whim and not have to worry too much about having to update preload.js. Of course the downside is that preload.js then needs to be sent to the client, with all the associated overhead of a get request.
2 – Append noConflict onto jQuery
There are those that will believe that the jQuery file is sanctimonious and should never be tainted by a developer’s touch. As it is I’m already using ASP.NET and cursed for all eternity, so how much worse could it be? So path two is pretty straightforward, open up the jQuery and jQuery.vsdoc files and add var $j = jQuery.noConflict(); to the bottom of the file. Again, this will sort out all the resolution gubbins while you’re working away in your own scripts.
Just remember that if/when you update your original jQuery files to also replace the noConflict statement at the bottom.
•
Wikis are wonderful collaborative tools for project development teams. They’re lightweight, straightforward and usually fit in well with the way most developers think most of the time.
But occasionally, just occasionally one of your developers may be something of a black sheep. Maybe they don’t like the way a certain part of your corporate wiki looks, or want some customised behaviour for getting rid of irrelevant parts of the page. Maybe they want to improve their productivity (I know, an alien concept).
Take for an example a project I’m currently working on. One of our wiki pages is a rolling todo list, where new items are added under various categories as additional <li< elements in a list and as tasks are completed they’re struck out with a <del> tag. As you can imagine, after a while, this page has become something of a swamp of strikethroughs and it makes it very hard to judge the amount of work remaining.
In some cases, custom stylesheets may be adequate. But in other cases, you may need a little more flexibility. “User Scripts” are a recently modern concept that have been popularised through the Greasemonkey Firefox extension for use with common web application such as Flickr, Facebook and Gmail. User scripts provide flexibility above and beyond the scope of the original application.
So why not apply this to wikis as well? So today, I wrote the world’s smallest user script to hide the deleted lines in the wiki:
$(document).ready(function () {
$("del").parent().parent("li").hide();
});
You’ll notice that I’m using JQuery rather than vanilla Javascript. JQuery is my library of choice and there’s no reason why you can’t use yours either. There are a few solutions for loading JQuery at runtime, my preference is to simply copy the compressed version into the header of the script. Since the script is loaded locally, the additional 50k is neither here nor there.
For the Safari lovers, there’s also GreaseKit (Mac OS X only alas), which provides similar functionality. I’m currently using this since I’ve given up on Firefox for a while (I blame Caius).
Now I’ve got a cleared down wiki and I can focus a bit on what I’ve got left to do. You can too. Or comment with an idea for novel wiki functionality.
•
I’m proud to announce the first release of the Massive Dev Chart for Android. For those in the know, the Massive Dev Chart is an invaluable online database containing thousands of tested combinations of developers and films for Black and White development.
A portable version of this information already exists for the J2ME platform, and has been in existence for some time. But with the advent of the next generation mobile platforms, there was a gap for a new application to fill the void.
The Massive Dev Chart for Android goes beyond the remit of the original application by providing real-time search facilities for developers and films, providing information for small, medium and large format, and providing crucial extended information where it’s needed.
This is the first in hopefully a line of Android applications from Orange Tentacle and is available in the marketplace on your G1 now.
•
Had a headdesk moment as I sat down this morning to write a delivery page for a web site I’m current working on. I needed a table of countries, their ISO numbers and two and three letter codes. I’ve done this once or twice before, but had misplaced the script to rip the data from wikipedia and generate the insert statements. I thought I’d run around the web to see if anyone else had the common sense to do the same thing and plonk it on the web.
Lo and behold, the gentleman here has already done it for us. I think he deserves a round of applause and a cup of tea for saving me ten minutes work.
•
I often end up working in collaborative environments, with SQL Server accounts which only allow me access to one database on any given server. Using the SQL Server 2005 tools, this wasn’t a problem. SQL SMS showed me all the databases available but threw an “access denied” if I tried to do anything to them. Fairy nuff.
SQL SMS 2008 however refuses to show the databases in the object explorer. I can open a new query window, switch to the database and access it via T-SQL, but I can’t directly interact with any of the databases as I could with SMS 2005.
Turns out that when SQL SMS 2008 probes each of the databases, it’s also checking for the collation of the database. If the user doesn’t have read access to the database SQL SMS throws an exception which stops it from probing any further and returns an empty list of databases. To get around this you need to turn the collation checking off. To do this, select “Databases” in Object Explorer, then press F7 which opens the “Object Explorer Details”. Right click on the columns across the top and deselect “Collation”. Right-click, “Refresh” your databases and you should be able to see them all again.
•
It’s one of the first keywords every programmer is taught, and it’s the first real sense of control you’re given over your programming. It’s translated into almost every language (there is the odd exception, and they are odd) and makes the basis for every conditional statement there-in.
Yes, we’re talking about the “if” statement. Everybody is familiar with its structure – if condition x is satisfied do this, or else do that, where this and that can be as flexible as you like. Alternatives exist, although most programmers seem to learn to “switch” and stop there. Because all their use cases can be covered with the “if” statement, programmers can become dependant on the “if” statement to perform functions that are better suited by other operators or keywords.
Why make the effort? This boils down to maintainability and readability. By using the most appropriate method to define your “if”, you explicitly state your intended purpose. When the next programmer comes along to maintain your code, or if you revisit your code after a significant time (say a week) the meaning of the statement is inherently obvious and rather than wasting time attempting to understand the complexities of the “if” blocks, you can concentrate on more important things. This is always a good thing. There may be some performance benefits (or occasionally losses) to some of these methods, but for the moment we are focusing on maintainability and readability of your code.
Read more »
•
One of the main criticisms of the ASP.NET AJAX approach is the “all or nothing” attitude the components have regards callbacks and updates. This is both a blessing and a curse, for while the AJAX components are very easy to work with, they also introduce significant network overhead and come with their own set of caveats.
Microsoft recognised this, and realises there was a need for a set of Javascript tools as part of the .NET stack to provide better generic Javascript support and to provide some AJAX alternatives. Rather than design their own from scratch, Microsoft decided to provide support for the very popular JQuery library. As of Visual Studio 10, JQuery will be distributed as part of the development kit, but for now you can get a head start with some early support released for Visual Studio 2008.
After the cut, we’ll discuss adding support for JQuery to Visual Studio.
Read more »
•
I use generic handlers (.ashx) quite a bit when working with client side Javascript, they’re a good way of getting data to and from the client. I’ll do an in-depth post at some point showing a nice way of chaining generic handlers, JQuery and JSON in a quick way of writing AJAXesque web apps.
For the moment though, a quick tip for people needing access to their session variables in handlers. Because a generic handler is stripped down to its bare bones, you’ll need to import your session state by including a specific interface.
using System.Web.UI.HtmlControls;</p>
<p>public class GenericHandler : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;</p>
<pre><code> context.Response.Write(context.Session["name"]);
}
public bool IsReusable
{
get
{
return false;
}
}
</code></pre>
<p>}
Also remember that your session now exists as a property of the context, remember to address it as such.