Archives

Archives / 2008 / June
  • MOSS | Custom Field, drop down auto select hell

    Tags: .NET 3.5, SharePoint

    The more I work and develop with SharePoint I am learning that 95% of the task, with a little guidance is a walk in the park, especially when compared to that final 5%, which is either impossible or is the most painfully experience any developer can experience!!

    Take my Friday hell for an example...

    A requirement comes in for custom news item, with a property that is the users department, but could be changed to another. Sure i think, drop down control, bind to all the possible departments, auto select the user department, getting the value from the users profile.

    Converting that into SharePoint, create a custom field, inherit from SPFieldChoice, bind to an SPList with all the groups (add to the base.Choices collection), get the current user from the SPContext, use that to the query the users profile to get the department, set the base.DefaultValue. Cool, now that is sweet, test in a simple column adding to a list, works a treat. The field is wanted for a page content type though so...

    Create a site column, add to content type, create custom page layout, drop on...we are rocking so far.

    Go to create a page and my group is selected, awesome. Change my group just to test, but nope still selects old group...hmmm...iisreset....nope the same. Test with other users, the same!! Just to confirm, its not selecting the first item in the list, its selecting the department of the admin user who deployed the solution, and what it was when they deployed it!!!!! Now that is nuts, go into a standard list, works a treat!! After hours of thrashing, trying to add it directly as a column to the page library and many others i gave up and came up with a far less appealing solution but a solution none the less....so what the feck is going on here???

    Its worth noting that i put some trace code in and found that the correct department was being pulled through, and checking what base.DefaultValue was after setting it showed it was what I expected, but on the page was the admin's original group. If anyone else has experienced similar it would be great to here from you, I can post some code if you like, but its pretty simple stuff and like i said, works in standard items.

    I did actually take the time this weekend to create a custom field rendering my own drop down list, the value is auto selected as I would expect, but I the value doesn't display in the "View Properties" or "Published Page" mode, fine in "List View"....its metal!

    P.S. I have another one to with sub classing the CQWP, that I might post later.

    more...

  • Cricket Club Starter Kit CodePlex project

    Tags: .NET 3.5, ASP.net, Personal

    I mentioned a while back that I had something I was working on that involved a change in language, actually a pretty radical change. I have been working on vocational project written in VB.net and made heavy use of LINQ to SQL. I wasn't sure of LINQ to SQL for anything else other than RAD and to be honest I'm still not. Anyway, I'm not getting into that debate. Needless to say I went all the way and don't use a single sproc in this project.

    Some of you will know I play cricket every Saturday for a local club (nothing special, just for fun!), well for a couple of years I have been thinking of putting a website together for the club, just never got round to it. However the other day I was looking at the starter kits on the asp.net website and came across The ClubSite v2.0, also hosted on codeplex, basically this is built on top of the original ClubSite, it adds functionality and has layered the code. Problem is, its American and the statistics part of the site relates in no way to cricket, which is a pretty statistics intensive sport.

    I decided to write the cricket stats engine (that sounds fancy!), and take the opportunity to write some real code in VB.net and LINQ to SQL. I have pretty much completed this project on my train journey to and from work, which is about 40 mins each way. Working on it not every day, but most for the past month.

    The original ClubSite makes use of submodal for its AJAX functionality and some modal popups, I am not really a fan of these and found them to work erratically so have replaced a few and plan to do the rest, using the asp.net AJAX control toolkit modal popup. I have also added update panels to make the UI some what slicker! I code is in no way of a work of art, that's not really been the point of the exercise.

    I haven't finished the project, apart from very limited testing, I plan on using silverlight (to tick another "must learn more about" box) to create some pie charts etc to better represent the data. I have actually found some open source examples i intend to download soon.

    I appreciate that cricket is a pretty captive audience and cricket playing geeks are no doubt even less, but hopefully I will get some downloads and help if finding bugs and enhancing the project. I have actually only found 1 other site that does cricket statistics and that is a national site and every club has a sub-site within the main site. Far to restrictive for my liking.

    Go and check the project out here: Cricket Club Starter Kit

    It's also worth mentioning that I haven't changed any of the original ClubSite v2.0 code, I have simply added on to it, mainly because I don't to miss out on anything that gets released/fixed with that project. Apart from perhaps a link of two in the menu to point to my new CricketStats folder and the graphic from a football (soccer ball) to a cricket related image. I haven't even fixed bugs that I have come across, that isn't the point of this project. On Codeplex I have checked all the code in, including scripts to create the schema in the db, but not all my test data (yet). I'm not sure if this is the best way to go about it, it might be better to simply check in the new code and some scripts to incorporate it in into the clubsite v2.0. That might over complicate the whole development process though.

    A Few screen shots to give you a flavour!

    Games in season overview - (Default.aspx)

    clip_image001

    Game Statistics

    clip_image002

    Team Statistics for the season

    clip_image003

    Player Statistics by season

    clip_image004

    ADDING AND INSERTING DATA

    clip_image005

    clip_image006

    more...

  • Postbuild script for Sharepoint project in Windows 2008 and Visual Studio 2008

    Tags: SharePoint, Visual Studio

    Now that is a bad ass title!!

    Anyone who has been through the MindSharp training course for SharePoint and any others that have looked at any code Todd Bleeker puts out there will most certainly be aware of using post build scripts in Visual Studio to deploy your sharepoint project.  This knowledge is of course not limited to MindSharp grads, its just that being one I know what they know!

    To get them to work in a Windows 2008 and Visual Studio 2008 environment you will need to make some changes.  As pointed out here, GacUtil has moved so the command will change from

    this

    "%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\GacUtil.exe" /if "$(TargetPath)" /nologo

    to this

    "%programfiles%\Microsoft SDKs\Windows\v6.0A\bin\GacUtil.exe" /if "$(TargetPath)" /nologo

    ...and the command to recycle the app pool in IIS7 has changed, if you try the old way you will most likely get a Microsoft.CmdLib error when building from VS.  The required command has changed from

    this

    "%systemroot%\system32\iisapp.vbs" /a "[YourAppPool]" /r

    to this

    "%systemroot%\system32\inetsrv\APPCMD" recycle apppools "[App Pool Name]"

    This is as much for me as everyone else as I no doubt will come up against this again!

    For completeness here is my postbuild script for a custom field project, you might not want to copy the debug pdb file or create a solution (last two commands)

    cd "$(ProjectDir)"

    "%programfiles%\Microsoft SDKs\Windows\v6.0A\bin\GacUtil.exe" /if "$(TargetPath)" /nologo

    "%systemroot%\system32\inetsrv\APPCMD" recycle apppools "App Pool Name"

    xcopy "TEMPLATE" "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\" /ys

    xcopy "$(TargetDir)*.pdb" "%systemroot%\Assembly\GAC_MSIL\OC.Sharepoint.FieldTypes\1.0.0.0__[token]\" /ys

    MakeCab.exe /f FileName.ddf

    more...

  • Foo Fighters | Wembley

    Tags: Personal

    My first trip to the new Wembley stadium was to watch the Foo Fighters gig on Saturday night, who as far as I am concerned are the best band on the planet right now. They did well to beat Oasis to that accolade, but heh, Oasis haven't done anything for quite a while now!! For those that don't know Wembley is a 90K seater stadium in London and the Foo's sold out in about 15 mins back in December, typical to big show form they promptly announced a second night (which was Friday), and that promptly sold out :)

    The show was pretty awesome, I was quite a way back in the stands, but was directly in front of the stage so had a pretty good view. I don't have a great camera or indeed an eye for a good shot, but here are a couple of photo's.

    Led Zeppelin came on at the end to play Rock and Roll and Ramble On, Dave Grohl declared it as the best day of his life, I had fun, but not that much!

    The Carlsberg one was taken by the missus, a birthday present idea perhaps! ;-)

    foo_wembley_1 

    foo_wembley_3

    foo_wembley_2

    Technorati Tags: ,

    more...