Steve Clements

.Net and then some....


News

Search



MCP

Add to Google
Add to Technorati Favorites



Subscribe to this Blog by Email


this is Steve's profile
Locations of visitors to this page

My Stats

  • Posts - 124
  • Comments - 138
  • Trackbacks - 52

Twitter












Tag Cloud


Recent Comments


Recent Posts


Archives


Post Categories


Image Galleries


Fav Blogs


Fav Places


Services!


Top Kudos



I had a little mishap last night at the driving range...

Needless to say I am now in the market for a new driver...I never liked the sound of that one anyway!!

 

 

Technorati Tags: ,

After watching a DNRTV episode with Scott Cate on EasyDB I was really impressed and could definitely see how it could solve a requirement in a project I am planning...

Straight after listening to the show, with the advice of Scott Cate (a promotion code), I hot stepped over to http://easydb.com to sign up.  After waiting for a few days, maybe a week and still having heard nothing I tried again and was greeted with this little chestnut...

 

image 

...and that remains to this day.

Why bother doing a dnrtv episode then not letting me in to try it, blog about it and generally test it???? Pointless...

Anyone else using this beta that may have the power to let me in?!?!


iphone Its my birthday in a couple of weeks and as a present my girlfriend bought me an iPhone...its an early present, but she's been going to the o2 shop for the last couple of weeks and this is the first time they have been in stock.

Anyway, she is a gem, because she used her contract so I could get it! I had too long remaining on mine! (Which means for the first time in about 5 years my mobile number has changed, which is probably a good thing, anyway, if you haven't got my new number and want it, contact me!)

Here are my thoughts on what is probably one of the most hyped gadgets I have ever known...

With IFAF ratings, IFAF you say? I fone acceptance factor i.e. what am I willing to accept just to keep using my iPhone!! Its funny what's forgiven when presented with one of the best user experiences ever...

  1. Battery life: I have always looked at battery life as fairly important when shopping for a mobile phone, but here I am re-charging with less that a full days use. IFAF: Tolerate - Not enough to send it back. Mind you, why couldn't Apple just allow spare batteries to be used? Compromise design perhaps...such apple bollocks!
  2. SMS functionality: what do I mean? Well, I cant save text drafts, I cant forward messages, no MMS - what's that about? Ahh...I should email everything/one...well, not everyone has as easy and consistent access to email as me(us)!! IFAF: Pushing it - I don't send a great deal of text messages, but I do often prepare ahead of time and send pictures of humorous things to my misses! (my sea monkeys being the latest thing!)
  3. Tariffs: I cant speak for all carriers, but here in the UK o2 have the exclusive contract for iPhones and aren't shy about exploiting it. Currently (still with o2) I pay £25 per month for more minutes and texts than the £35 iPhone contract, and about 500% more than the £30 contract that is surely just a token deal which is so shite that no-one will take it and go for the £35. take a look here http://o2.co.uk/iphone/paymonthly IFAF: its only money right! I want an iPhone!!
  4. iPod: Of course the iPhone has an iPod built in with the same interface as the iTouch, which is so silky it slippery to the touch! However, in iTunes (which I like by the way!!), you cannot simply drag and drop albums like my iPod, I can only sync playlists, reading around the accepted method seems to be create a single playlist, drop all music into that and sync that one! IFAF: Takes the shine off - this is crap really, a big part of this gadget for me is that my beloved iPod will be built in...with the major addition of touch!! The fact that others have raised this means I'm not alone...its another big WHY? For the apple bods. It just takes the shine of an otherwise perfect feature.
  5. Camera: The camera i think is only 2MP...which is well below par. IFAF: Tolerate - i dont use it a great deal and accept that a phone wont take great photos.
  6. Radio: I do miss not having a radio, but then again the battery would be flat before I got to work! IFAF: Tolerate - I can happily live with out, I have never used a "phone radio" that was much good anyway!

These few gripes however no way make up for a how silky and smooth to use it is. The keyboard is awesome, the email interface (even with the IzyMail nonsense because I use live mail, not gmail - Izymail is sweet, the fact that Live mail doesn't do POP3 is nonsense) is one of the best I have ever used on mobile device - Blackberry is not even close. The GPS, although not a full blown Sat Nav is pretty mustard.

I also love the fact that custom apps get in on the action!!

I am yet to unlock (or JailBreak!) my iPhone, I haven't looked into it much and as yet have no reason to do so...anyone got reason why? What does it do for me?

I'm sure there are a few more gripes and I will come across as I get into day 3 of usage, but how much of a dent it will put into the weird power of the iPhone!


Check out my new live search component to the right here ->

I came across this on Heather Solomon's blog, thought it was cool so had a play and set one up for my blog.

To start with get yourself over to http://search.live.com/siteowner, select the advanced option.  I think it only works if you have your blog on a custom domain like blog.steveclements.net as www.geekswithblogs.net/steveclements doesn't work.  I also created a live search macro for geekwithblogs.net and used and existing one for msdn sites and blogs.  Creating your own macro is very straight forward, well the basic one is, I didn't actually look at what the advanced offered.

Here you can see the four tabs for different search results.

image

The live.com tool generates the code for you, but I had to make a couple of changes to get it to look right (background-color: White, add a search title) and fit (reduced the width).

I am pretty excited about this, I have used google and live search before just to find content on my own blog so this is definitely going to get lots of use, with geekswithblogs on there makes it even more useful, I often remember a post from the geekswithblogs feed, but cant remember who posted it.  With MSDN and web makes it pretty complete I reckon!

Heres the code.

To get it to show in the blog paste it into admin settings -> options -> configure -> static news/announcement.

<!-- Live Search -->
<meta name="Search.WLSearchBox" content="1.1, en-GB" />
<div id="WLSearchBoxDiv">
<table cellpadding="0" cellspacing="0" style="width: 185px">
<tr>
    <td style="font-weight: bold;padding-right:5px;text-align:left;">Search</td>
</tr>
<tr id="WLSearchBoxPlaceholder" style="background-color:White;">
  <td style="width: 100%; border:solid 2px #4B7B9F;border-right-style: none;">
  
  <input id="WLSearchBoxInput" type="text" 
value="&#x4c;&#x6f;&#x61;&#x64;&#x69;&#x6e;&#x67;&#x2e;&#x2e;&#x2e;"
disabled="disabled"
style="padding:0;background-image: url(http://search.live.com//siteowner/s/siteowner/searchbox_background.png);background-position: right;background-repeat: no-repeat;height: 16px; width: 100%; border:none 0 Transparent" /> </td> <td style="border:solid 2px #4B7B9F;"> <input id="WLSearchBoxButton" type="image"
src=http://search.live.com//siteowner/s/siteowner/searchbutton_normal.png
align="absBottom" style="padding:0;border-style: none" /> </td> </tr> </table> <script type="text/javascript" charset="utf-8"> var WLSearchBoxConfiguration= { "global":{ "serverDNS":"search.live.com", "market":"en-GB" }, "appearance":{ "autoHideTopControl":false, "width":800, "height":550, "theme":"Green" }, "scopes":[ { "type":"web", "caption":"&#x53;&#x74;&#x65;&#x76;&#x65;&#x20;&#x43;&#x6c;&#x65;&#x6d;&#x65;&#x6e;&#x74;&#x73;", "searchParam":"site:blog.steveclements.net" } , { "type":"web", "caption":"&#x47;&#x65;&#x65;&#x6b;&#x73;&#x77;&#x69;&#x74;&#x68;&#x42;&#x6c;&#x6f;&#x67;&#x73;", "searchParam":"macro:steveclements.geekswithblogs" } , { "type":"web", "caption":"&#x4d;&#x53;&#x44;&#x4e;", "searchParam":"macro:livelabs.msdn" } , { "type":"web", "caption":"&#x57;&#x65;&#x62;", "searchParam":"" } ] } </script> <script type="text/javascript" charset="utf-8"
src="http://search.live.com/bootstrap.js?market=en-GB&ServId=SearchBox&ServId=SearchBoxWeb&Callback=WLSearchBoxScriptReady">
</script> </div> <!-- Live Search -->

Silverlight makes working with videos pretty straight forward, Microsoft makes Silverlight pretty straight forward with ASP.net and sharepoint is written in ASP.net, so match made in tech heaven!!

I wanted a video player web part for sharepoint, that had some simple functionality like play, pause and volume.  I started with expression encoder which output a nice media player interface...this is OK, but has a couple of restrictions; 1, its far to rich for what I wanted, animations all over the place and 2, its JavaScript with Silverlight 1.  So, using blend I opened one of the exported files to rip out a few features of the player.

Play / Pause button, volume control and some associated storyboards for some nice animations... visible = true; visible = false is so last year!!!

I copied the xaml into my own Silverlight 2 app, that already had the media player element.  A little positioning in blend and we're off.  Right that's far too much waffle lets get to it!

image

I wont paste the xaml here as it basically only a media element, the play/pause button and volume control copied from Expression Encoder. OK, well maybe a little...

<MediaElement HorizontalAlignment="Stretch" Margin="0,0,0,0" x:Name="MediaMain" VerticalAlignment="Stretch" Source="" Stretch="Fill" AutoPlay="False"/>

What I did add was handlers for all of the events e.g. Play, pause, volume (actually all the code to do the slider) and hide/show events for the play button.  More on that in a mo.

Of course for this to be a web part, the movie file at least has to be a variable that's changeable in the properties of the web part.  To do this I am going to use Silverlight's InitParams property.  Its worth mentioning that the movies are nothing to do with me...they are going to live in a sharepoint library, they are encoded into wmv format using another app.

In the App.xaml file within your Silverlight project you will find an OnStartUp method, this is where I handle the InitParams.

        private void OnStartup(object sender, StartupEventArgs e) 
        {
            this.VideoUrl = string.Empty;

            if (e.InitParams["videoUrl"] != null) {
                this.VideoUrl = e.InitParams["videoUrl"];
            }
            if (e.InitParams["AutoPlay"] != null) {
                this.AutoPlay = Convert.ToBoolean(e.InitParams["AutoPlay"]);
            }
            else {
                this.AutoPlay = false;
            }
            if (e.InitParams["Loop"] != null) {
                this.Loop = Convert.ToBoolean(e.InitParams["Loop"]);
            }
            else {
                this.Loop = false;
            }

            // Load the main control here
            this.RootVisual = new Page();
        }

As you can see I am expecting 3 params and set class level properties for later use. AutoPlay(play the video on page load) and Loop play(to obvious to describe!!), VideoUrl (the url of the video to show).

public string VideoUrl { get; private set; }
public bool AutoPlay { get; private set; }
public bool Loop { get; private set; }

In the Silverlight class (Page) constructor I get the values like this...

        App currApp;

        public Page()
        {
            // Required to initialize variables
            InitializeComponent();

            currApp = Application.Current as App;

            VideoMain.Source = new Uri(currApp.VideoUrl);

            VideoMain.AutoPlay = currApp.AutoPlay;
            if (currApp.AutoPlay) {
                ControlsPlayPause.Opacity = 0;
                PlaySymbol.Opacity = 0;
                PauseSymbol.Opacity = 1;
            }

Here you can see I get the current application, cast it as App (insert whatever the name of your own application class is...App is default) and access the properties.  I am setting the source of the video and deciding whether to play or not, setting the UI to suit.

I have a couple of handlers on the UserControl to show the play/pause button.  Basically when the mouse hovers over the control show the button (begin the StoryBoard that animates it in)

        private void UserControl_MouseEnter(object sender, MouseEventArgs e)
        {
            if (ControlsPlayPause.Opacity < 1)
                PlayPause_Show.Begin();
        }

        private void UserControl_MouseLeave(object sender, MouseEventArgs e)
        {
            PlayPause_Hide.Begin();
        }

In the top one, I check for opacity, as you can see in the class constructor if the video is not set to AutoPlay I show the play button.

I don't use this, but for reference this is what the markup would look like to use this Silverlight app.

    <div id="silverlightControlHost">
        <object data="data:application/x-silverlight," type="application/x-silverlight-2-b2" width="100%" height="100%">
            <param name="source" value="ClientBin/VideoViewer.xap"/>
            <param name="background" value="white" />
            <param name="initParams" value="videoUrl=http://mossinstance/site/library/movie.wmv,AutoPlay=true,Loop=false" />
            <a href="http://Silverlight.2.0.exe" style="text-decoration: none;">
                 <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
            </a>
        </object>
        <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
    </div>

-----------------------------------------

Now onto the web part.  I am going to have the Silverlight app on the Sharepoint server, there are obviously several ways, one that appeals to me most is have a sharepoint library for your Silverlight apps, or it could be as simply as creating a ClientBin folder at the route of the site.  Don't forget you need to set the MIME type up for Silverlight.

The web part itself is pretty simple, all I need is 3 properties, create the Silverlight control and set the InitParams.

I do have a custom "NotInstalled" template, but you don't need that.  I didn't want users to have to download the installer from the web, so I have put it on the network. You will also see I have set the source of the Silverlight control to a ClientBin folder at the root of the site.

Another point to note(!) I have put the dll System.Web.Silverlight in the GAC, there are arguments for and against, I prefer the GAC.

Now install your web part in whatever method you prefer...

 

Some pages/sites/articles that helped.

I have literally just found this on codeplex, it's a Silverlight 1.0 video player web part for Sharepoint.  Would have been no good for me as I have no interest in Silverlight 1.0, but you might!!

 


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.

 


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

 


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


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: ,

posted @ Monday, June 09, 2008 7:28 AM | Feedback (0) | Filed Under [ Personal ]


LINQ goes so much further than just SQL and XML.

Something like this is just why I love LINQ, a LINQ query on an ASP.NET ListView controls items.

   1:  Dim items = From lvi In AspNetListViewControl.Items _
   2:              Where CType(lvi.FindControl("DropDownList1"), 
	                DropDownList).SelectedValue = someIntVar _
   3:     Select lvi)

 

Getting a ListViewItem's where the selected value of a DropDownList is set to the value I want.  So simple, yet so powerful.

The observant among you will notice that this is in VB.net, not my native C#!! More on that soon! :)

Technorati Tags: ,

posted @ Wednesday, May 28, 2008 5:01 PM | Feedback (0) | Filed Under [ .NET LINQ ]