Wednesday, 24 March 2010

Setting a TreeView node in focus

Lately I have been working on a couple of projects and one of them involved a fairly long ASP.NET TreeView control. The requirement was to have it so that when a user clicked on a node, the TreeView would have that selected node in focus after the postback. This proved to be a little troublesome as there is a built in method called HideSelection in the Windows Forms version however that property does not exist in the ASP.NET version of the control.
So while browsing the web, I noticed a couple of people were having the same issue with this control. I managed to hack together some JavaScript using some of the existing script provided by the .NET framework. The following code sets the currently selected TreeViewNode into focus.
function SetSelectedTreeNodeVisible(controlID) {
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;}
var selectedID = theForm.elements[controlID];
if (selectedID != null) {
var selectedNode = document.getElementById(selectedID.value);
if (selectedNode != null) { selectedNode.scrollIntoView(true); }
}
}

To use this code in your page, just call the function like so
SetSelectedTreeNodeVisible('<%= TreeViewName.ClientID %>_SelectedNode');

Replace TreeViewName with the name of your TreeView control. This code should be called at the end of the page so that the treeView has had time to load.

Tuesday, 23 March 2010

MCTS Web Applications .NET 4– 70-515 – Objectives List Part 6

This is the sixth post (first, second, third, fourth, fifth) in another collection of posts that have links to the different objectives covered in the 70-515 exam. There is also a series on ASP.NET 3.5 exam 70-562 (here) and Web Applications .NET 2.0 exam 70-528 (here)

Please note that information and exam is currently in beta and subject to change. This exam guide is for use at your own discretion and the author accepts NO liability in relation to incorrect or missing information. Also note that using this guide to study does not imply you will pass the exam

Developing a Web Application by Using ASP.NET MVC 2 (13%)

There are no books available for this exam at this time due to the fact that the exam is in beta until 30-April-2010. 8 weeks after this date is the expected go live date for this exam.

MCTS Web Applications .NET 4– 70-515 – Objectives List Part 5

This is the fifth post (first, second, third, fourth) in another collection of posts that have links to the different objectives covered in the 70-515 exam. There is also a series on ASP.NET 3.5 exam 70-562 (here) and Web Applications .NET 2.0 exam 70-528 (here)

Please note that information and exam is currently in beta and subject to change. This exam guide is for use at your own discretion and the author accepts NO liability in relation to incorrect or missing information. Also note that using this guide to study does not imply you will pass the exam

Displaying and Manipulating Data (19%)

There are no books available for this exam at this time due to the fact that the exam is in beta until 30-April-2010. 8 weeks after this date is the expected go live date for this exam.

Monday, 22 March 2010

MCTS Web Applications .NET 4– 70-515 – Objectives List Part 4

This is the fourth post (first, second, third) in another collection of posts that have links to the different objectives covered in the 70-515 exam. There is also a series on ASP.NET 3.5 exam 70-562 (here) and Web Applications .NET 2.0 exam 70-528 (here)

Please note that information and exam is currently in beta and subject to change. This exam guide is for use at your own discretion and the author accepts NO liability in relation to incorrect or missing information. Also note that using this guide to study does not imply you will pass the exam

Configuring and Extending a Web Application (15%)

There are no books available for this exam at this time due to the fact that the exam is in beta until 30-April-2010. 8 weeks after this date is the expected go live date for this exam.