tirsdag 27. oktober 2009

Visual Studio 2010 - the most exiting new stuff

I attended the MSDN Live Oslo a few weeks back where they talked a lot about the new versions of Visual Studio 2010, C# 4.0 and ASP.NET 4.0. I'll present some of the most exiting (to me anyways) new stuff.

C# 4.0

  • Named and Optional Parameters (no more overridden methods?)
  • Late-Binding support / Dynamic Lookup
  • Improved COM Interop
  • Dynamically typed objects (to be honest, this is scary. Pitfalls!)
  • Visual Debugger (visualization of your objects and their hierarchy)
  • Tasks/Parallels (no more threading! This is far more efficient and easy to deal with)
Visual Studio 2010
  • Historical Debugging (exiting!!! Step through your code as it ran on a live server!)
  • Totally rewritten in WPF
  • Improved designer (yet again)
  • Added a lot of features like in ReSharper
  • JQuery is integrated
  • More visual modeling tools
ASP.NET 4.0
  • Stripped down web.config file. Mostly everything moved to machine.config
  • Extensive Output Caching. More flexibility on what to cache
  • You can run start-up code for the application
  • Session State Compression
  • Individual ViewState
  • Much better control of your controls' client ID (myTextBox actually IS myTextBox!)
There is lots of other new stuff too obviously, but I just wanted to share with you the stuff that I think is most exiting.Can't wait for the full release!

mandag 26. oktober 2009

Creating a custom Field with TreeView in SharePoint 2007

I was faced with the task of creating a custom Field in SharePoint 2007 (WSS 3.0) which presents (in new and edit mode) a TreeView control with some hierarchical data. The user should click and select one node in the TreeView before saving the item.
Now, my challenge turned out to be what to save in the item. I had never created a custom Field before and still, as far as I can see, it's possible to only save one value for the field.
I needed to save both the ValuePath and the textual representation of the path to the selected Node.

The solution was to save both those values in the same string, separated by, by my choice, a '#' character. Now, in order to present the textual representation of this string in the Item's List's View, I had to implement a small JavaScript on the client to split the value and return the correct part of the string. The JavaScript looks like this:

function SplitString(theString) {
  var theStrings = theString.split("#");
  var theStringsLength = theStrings.length;
  if (theStringsLength > 1) {
     document.write("<div style='DISPLAY: block'>");
     document.write("<div style='WHITE-SPACE: nowrap'>" + theString[0]+ "</div>");
     document.write("</div>");
  }
}


Now, in Edit mode, it was straight forward to make sure to select the correct Node. I just did a split on the value again, and fetched to other value of the split (which in my case is the ValuePath of the Node) and did a myTreeView.FindNode(mySplitValue).Selected = true;.

This isn't very elegant and it hurts implementing this, but it works! I wish though, that there's a better way of doing this. I actually expected to have a 'View presentation' of the saved string (where I could format the string the way I wanted) and a 'Edit presentation' of the saved string. However, I couldn't find any. So, if anyone knows that it actually is possible and how, I would appreciate the solution :-)!

Have a nice day!

torsdag 24. september 2009

Just a post to get started

Stop reading if you're looking for valuable information! Actually, this is it!