Tuesday, July 25, 2006

New stuff in web parts for sharepoint developers

Some of you may be wondering why I have not posted in a couple of days. Well, there was the weekend, and then I started working on a set of two web parts that I want to publish here. I will keep them as a surprise, but I promise they will be open source if you promise not to send it to the http://thedailywtf.com!

Meanwhile, I will tell you about a couple of things I discovered while working on these web parts:

  1. I wanted to create two web parts in one DLL. This seems to be an easy task - exactly like making one web part - just add another class, inherit from "webpart" and make sure its has the same namespace and make sure that you register it as safe. Sounds easy right? Well - I managed to waste two days trying to make this work (and this should go to http://thedailywtf.com) because I didnt notice that the second class I added didnt have the "public" declaration (this is the default for a new class in visual studio). So I tried and tried and tried, and finally the good MVP Daniel Larson helped me find the small mistake.
  2. This is something new for developers - fields in lists now have new properties in the object model :
    1. ShowInDisplayForm
    2. ShowInEditForm
    3. ShowInListSettings
    4. ShowInNewForm
    5. ShowInVersionHistory
    6. ShowInViewForms
    I can see we are going to have so much fun with these properties! So many people who want today to show fields in the version history screen will be delighted to know this, as well as people who want to edit the forms but are reluctant to use frontpage (and with reason!) To bad these properties are only accessible through code. Adding these to the UI would have been great! I have not had the time as yet to actually use them (I just noticed them in passing) but I do hope they work like they sound (the msdn has "todo" in the documentation of these features)
  3. While we are at it - another nice addition to the field object "GetFieldValueForEdit". I dont know yet what it does, but I have my suspicions!
  4. Ahhh, this is a great one- "FieldRenderingControl". Again, no documentation and I had no time, but I think this is going to be a huge time saver for all of us developers who need sometimes to write alternative input forms for lists. Just think about it - the field contains the information of which control to use. I will have to check tomorrow how it works exactly with the default field types since it returns a "sharepoint webcontrol" and not a regular "web.ui control". I will update. (save me some time if you know - post a comment!)

So now you know that my secret web part has something to do with fields...I wont tell you ny more so I wont ruin the surprise!

No comments: