January 10th, 2008Yahoo! Weather Web Part
Yeah, I know. You’re thinking this is frivolous; “What’s the point?”, you say. Well this is my first web part and I decided to go with something a little less “high profile”. However, I am still happy with it and think its got enough of that cool factor to warrant a post here.
It accesses the RSS feed from Yahoo! Weather and parses it for use within the web part. The code I provided is designed to retrieve the weather information for our location (Visalia, CA 93277) but could be easily modified for yours. Or, if you wanted, you could add a TextBox and have the user submit their own zip code!
There is A LOT of styling involved with making it look this way. I will include the styles as well as the plate graphics (which turns to gray after sunset). I would suggest, if you plan to use my styles, that you read my previous post on “Customizing the order of your stylesheets“. It’s a bit more work, but I like to have all the styles for the webparts I’ve developed in an independent stylesheet and not have those styles overwritten by the INFAMOUS core.css
I didn’t build this in a deployable package (still learning that), so this is just the C# code. You will have to build it into a .dll and deploy it to the GAC or place it into the bin folder. You will also have to set the web part namespace to be trusted in your web.config. Google will be your friend on all of that.
If all of this is just too daunting then I suggest trying Dustin Miller’s approach using SharePoint Designer (wuuuhhh!?) . The only problem I found with this, is that the datalist web part created in SharePoint Designer could not be shared easily between sites and users would not be able to add it to their own content pages (without my intervention).
Here are the source files: weather_webpart.zip