August 2009


Everyone recognizes the problem with dropdownlists which are dependant on eachother. We select something from dropdownlist A and then dropdownlist B can be filled with items based on your selection in A. Simple to build with an automatic postback and event handlers on the controls, but nobody likes the page refresh. So time to get our hands on jQuery and JSON.

Let’s suppose we have an application page in which we have two dropdownlist:
<wssawc:DVDropDownList ID=”dropdownlistA” runat=”server”></wssawc:DVDropDownList>
<wssawc:DVDropDownList ID=”dropdownlistB” runat=”server”></wssawc:DVDropDownList>

With a simple jQuery script, we can hook up the two dropdownlists, so that a change in dropdownlistA triggers the loading of items in dropdownlistB without refreshing the page. We use the jQuery selector, select[id$='dropdownlistA'], because we know that the above tag is rendered by SharePoint as a select control. The ID however is prepended with a unique part, so we let jQuery search for select controls where the ID ends on our ID. Always use the complete ID you specify in the design file to avoid multiple results in jQuery select statements.

(more…)

I updated the post on adding or deleting nodes on Quick Launch. There were some problems with the previous code when adding nodes as childnodes of existing nodes.

You can find the original post, ‘Add or delete nodes on Quick Launch’, here.