Change the Home page in SharePoint

 
Happy New Year to Everyone!
Wow, it's been a while that I had the time to write a blog post. I was simply swamped over the last two months. Soo much has happened!
 
Now I look forward to a good new year and I wish everyone exactly the same!
 
Back to business!
Unbelievable, but after years of working with SharePoint, for the first time, I needed to change the home page. 2 seconds thinking, 20 seconds googling - only to come up with ideas like doing this programmatically ...nuh, this had to be simpler.
 
Hey, what about SharePoint Designer? And there it was, the "Set as Home page" command! It couldn't be more simple :-)
 
Set as Home page

Published: Jan-04-11 | 0 Comments | Link to this post

"This List" contextual scope missing in the Scopes Dropdown

Now that was weird... The "This Site" contextual scope was showing in the Scopes Dropdown, but the "This List" scope was not showing at all on any list:
 
This List Scope Missing
 
I checked and changed the DropDownMode property to see if that would bring the "This List" scope back ...but no.
 
Call it "years of trial and error" experience to find the solution for this problem: turns out that accessing the site with the "Custom" zone (configured in AAM as "http://localhost") was causing it ...when accessing the site with the "Default" zone (configured as http://2k8x64Moss) the "This List" contextual scope shows just fine ...I'd call that a bug, MS probably calls it a feature ;-)

Published: May-11-10 | 0 Comments | Link to this post

Custom List Forms with Code-behind

There are a lot of articles on the web about manually modifying the list forms and the ListFormWebPart in particular, but there isn't that much information about modifying these forms programmatically, and the problems that come with that.
 
To start with, there's a great article on SharePoint List Forms by Hristo Pavlov that I highly recommend.
 
Customizing the ListFormWebPart is a chapter by itself, but what we needed was to customize the EditForm.aspx. Actually, we needed to inject a control that would prevent the form to come up while the asynchronous "ItemAdded" event, triggered by a file upload to the library, was still busy retrieving metadata (also an adventure in itself, as I consider that clearly a conceptual bug in SharePoint), which would result in an exception and a failure of the upload and/or the metadata extraction.
 
Now, there are actually two levels of forms one could utilize: each list/library has a set of these forms (New, Display, Edit) and the content types that are associated with the list/library also have these forms.
 
We chose to replace the EditForm.aspx of the document-type content types with a custom aspx form with code-behind. Why code-behind? Well, there are actually a couple of things one needs to adjust on the fly to make this work. One example would be that a custom application page should reside in the "_layouts/" space and the default.master masterpage that is used by the list forms is not directly accessible from there. But the most important reason was that the ListFormWebPart requires the "ListName" (it's actually the Guid ID of the list) and the "ListItemId" (which is what it sounds like :-) to be set properly when the OnInit event fires.
 
ListName&ListItemId
 
So, where's the problem? The ListFormWebPart is an incredibly flexible piece of programming art that can render itself on the fly automatically, depending on what list, content type and columns are to be displayed, BUT it does not retrieve the ListName and ListItemId from the Page.REQUEST automatically. Alright, we can do that with the code-behind, but that's NOT the problem ;-) The problem is that the control isn't available during the OnPreInit event to set these properties, and before the OnInit event handler gets fired SharePoint already throws an exception stating that no item could be found for the list and itemId specified ...Duhh!
 
Well, the solution is actually (as most things in life) trivial: the OnInit event fires on the controls before it fires for the page. Therefore it is important to add a code-behind event handler not only at the page level but also for the Web Part itself:
 
WebPart OnInit event handler registration
 
And the rather simple code-behind for this looks like this:
 
        protected void Lfwp_OnInit(object sender, EventArgs e)
        {
            string listId = Page.Request.QueryString["List"];
            string itemId = Page.Request.QueryString["ID"];

            ListFormWebPart lfwp = (ListFormWebPart)sender;
            lfwp.ListName = listId;
            lfwp.ListItemId = Convert.ToInt32(itemId);
        }

 
The beauty of this solution is that the same custom EditForm.aspx can then be used not only for all Picture Libraries, but also for Document Libraries.

Published: Oct-12-09 | 9 Comments | Link to this post

Introducing Sahil Malik, Waldek Mastykarz and Paul Culmsee

Knowledge helps. Knowing how to "google" something helps too (sorry for the bias, I just never seem to find what I am looking for on search.live.com).
 
As the SharePoint 2007 documentation is still short on a lot of things, I still seem to end up relying a lot on blogs, when in need of looking something up I don't deal with on a daily basis.
 
Instead of simply pasting my by now ultra-long Favorites list of SharePoint-related blogs here, let me introduce them over the coming weeks with short posts that also tell what I like about these guys and gals.
 
Sahil Malik's Blog covers a broad spectrum of SharePoint topics, mostly on the development side. In some of his recent posts he's covered the integration of WCF and SharePoint, which sounds really promising to me. He also writes good articles that he references from his site. The last one is on the WCF & SharePoint topic.
 
Next up is Waldek Mastykarz: he also provides lots of development-related SharePoint information. WCM is a major topic on his blog. One of my favorites amongst his posts is his endeavour to extend the valuable Content Query Web Part.
 
Last but not least is Paul Culmsee. His blog posts provide in-depth information and are just fun to read. As an example: his series on SharePoint Branding covers the complexity of branding options in SharePoint very well.

Published: Nov-29-08 | 2 Comments | Link to this post