Thursday, September 27, 2007

Good Questions & Previews!

Hey Folks!

I've recently been getting a lot of really good questions. Everything ranging from uses of SharePoint Designer to Code Behind. What I'd like to do is set up a FAQ area where I can post all of the really good Questions & Answers.

I'd also like to give a preview into some of the posts that I'm working on:

  • SharePoint Form Controls
  • Site Definitions Part 2
  • List Definitions
  • Tying All of this XML together
These few topics seem to be avoided on blogs & documentation. I feel that they are significant in understanding how SharePoint Works and why things interact the way they do.

Hope this helps,
~:)

Monday, September 24, 2007

Using SharePoint Form Controls

Hey folks,
I've gotten a few requests on the approach to using SPlist New/Edit forms in there web parts. Well it's your lucky day! This blog has a pretty good post on how to use SPWeb Controls, not to mention they have a pretty nice set of source that can give you a jump start.

http://www.hezser.de/blog/Lists/Beitraege/Post.aspx?ID=38

Although this is a good start, there are a lot of little things you have to look out for when creating adding new/Edit forms to your webparts. Updating these fields incorrectly can really put you in a bad place. In good nature, I'll do a post on exactly how to use there source and some of the pitfall to look out for, but now... here's some food for thought!

Hope this helps,
~:)

Tuesday, September 18, 2007

List View Control (Quick way to embed lists into a webpart)

Hey folks!!!
It's been a pretty long time. I've been on a lot of projects in between and have been pretty much heads down since the last post. I figure I'll start off the next few rounds with a use control that across the board called the List View Control.

The SharePoint List View control is a very useful control that is leveraged in the ListView WebPart to display List. It's location is in the common Microsoft.SharePoint.WebControls namespace and it only needs a 2 properties to really show all of it's value. Internally this control interprets List Views and field values and renders them in a SPGridView control. It's nice to be able to simply leverage this control without doing all of the work.

Here's a code sample that should explain exactly how to use it:

namespace TAS.Examples
{
class ListViewExample : System.Web.UI.WebControls.WebParts.WebPart
{

Microsoft.SharePoint.WebControls.ListView view;

protected override void CreateChildControls()
{
view = new ListView();
SPList list = SPContext.Current.Web.Lists["
view.ListID = list.ID;
view.ViewID=list.DefaultView.ID;
Controls.Add(view);
}
protected override void RenderContents(writer)
{
view.renderControl(writer);
}
}
}

This is only a light sample of what you can do with this web control. By leveraging this control you know longer have to fight with an SPGridView Control or leverage the "RenderAsHTML" method of a List just to enable your WebParts and pages to leverage SharePoints Out of the box list capabilities.

Hope this helps,

~:)

Wednesday, July 25, 2007

CAML Query Designer

Hey Folks,
I posted previously on CAML.NET, but this tool by John Holliday is truly amazing. He's really doing an outstanding job at abstracting CAML in a very simple and intuitive way. Check it Out:

CAML Designer


I totally love it! Great Job.
~:)

Adding External Javascript files into SharePoint

Hey folks,
This is a quick helpful explanation of adding script files into SharePoint (WSS 3.0/MOSS 07. Let's jump right into some theory.

WSS 3.0 keeps all of it's external script files in 12/Templates/Layouts/1033. This localized managed path hosts common file such as "core.js" and other external resources. It's becoming a common task to include custom JavaScript in SharePoint pages that is registered. One of the "nifty" controls that WSS 3.0 offers is the SharePoint ScriptLink control (< SharePoint:Link />), this control allows a developer to link to external script file living in the localized managed path. Here's a practical example that should shed some light on the subject:

1.) Include the following in an external javascript file named "batman.js".


document.write("I am the night.");


2.) Copy "batman.js" to 12/Templates/Layouts/1033.

3.) Now add the following control to the head of your masterpage:

< SharePoint:Link ID="Batman" language="javascript" name="batman.js" />


That's it! Just upload the masterpage into the masterpages gallery and you should see "I am the night" printed on your pages every time they load. This control will become very useful when you begin to use new technologies like "Silverlight" or integrating the "oh so holy" Flash into SharePoint.

Hope this helps,
~:)

That's it

Thursday, July 12, 2007

Adding a custom Global Link !

Hey all,
This one is definitely a very useful little trick to know. In this walk-through we'll add a custom link to the global links section of a Master Page.




There are many ways to do this task, we'll be leveraging the
MyLinks control in this scenario.

Let's give it a go!

1.) From the 12 Hive navigate to 12/Templates/Control Templates.

2.) Open the MyLinks.ascx Control Template.

You'll notice that this control template is very straight forward, containing mainly a table and a single control (the actual My Links Control). We'll add link to Google in the global site section.

3.) Modify MyLinks.ascx to look as such:


< %@ Control className="MyLinksUserControl" Language="C#" Inherits="Microsoft.SharePoint.Portal.WebControls.MyLinksUserControl,Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" % >
< %@ Register Tagprefix="OSRVWC" Namespace="Microsoft.Office.Server.WebControls" Assembly="Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" % > < %@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" % > < %@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" % >
< table >< tr >
< td class="ms-globallinks" >< SPSWC:MyLinksMenuControl id="MyLinksMenu" runat="server" / >< /td >
< td class="ms-globallinks" >< asp:Literal id="hlMySiteSpacer" runat="server" / >< /td >
< td class="ms-globallinks" >< a href="http://www.Google.com" > google < /a >< /td >
< /tr >< /table >



That's it! Reset IIS and you'll notice a brand new link in the global links section of your masterpage.

You're probably thinking, "Why not hard-code the link into the masterpage?"

That's a good question. In theory everything in WSS 3.0 / MOSS 2007 is based on standard ASP.NET 2.0, so you can very well just hard-code a link into the masterpage or even create your own custom control and add a reference to it by leveraging a delegate control ( http://www.theartofsharepoint.com/2007/05/creating-custom-control-feature.html ). As developers we only need to remember that SharePoint is built from ASP.NET and with that understanding nothing is too much of a leap.

Hope this helps!
~:)

Friday, June 29, 2007

Failed to Create Web Application

In the past few weeks I've come across this error a lot, Scot Hillier does a nice job of shedding some light on this issue:

SharePoint 2007 Web Application Creation Fails


Scot mentions the "WSS Timer Services" being the source of the issue. After doing a bit of research, the Timer Services are very resource intensive (memory). Some of the side affects you'll notice when the Timer Service is the culprit include:

  • IIS Manager fails to locate the "localhost"
  • Event Viewer will consistently contain "memory corrupt" errors directed toward WSS Application Timer Service.
  • Pesky COM errors when creating a Web Application
At the moment the best bet with this growing issue for now is to schedule regularly recycle the WSS Timer Service to free up the overwhelming leaks and adjust the memory allocation to your WSS Timer Service for best results.

Hope this helps,

~:)