Thursday, March 12, 2009

Announcing the Accessibility Kit for SharePoint (AKS) v2.0

Microsoft and HiSoftware are pleased to announce the release of the Accessibility Kit for SharePoint (AKS) v2.0. The AKS v2.0 provides an accessible development framework and significantly reduces the level of effort and knowledge needed by customers and partners to improve the accessibility of SharePoint based sites and applications.
You can download from url:http://www.hisoftware.com/

Thursday, March 5, 2009

Propagate Content Type Changes

There is a common problem of propagating changes to content types deployed via a Feature.
I found solution for this problem by extended stsadm wroted by Søren to propagate changes.
You will find extended stsadm in this url:
http://stsadm.blogspot.com/2008/05/propagate-content-type-changes.html

Sunday, March 1, 2009

ValidationGroup in SharePoint 2007

The situation

You have an ASP.NET control that contains validation controls in the masterpage or page layout for a publishing site (an ASP.NET login control for example). When you try to edit and check in a publishing page you receive the following error.
This page contains content or formatting that is not valid. You can find more information in the affected sections.

The problem
Even if you fill in all the required fields on the publishing page, the validation controls on the other ASP.NET controls prevent the page from saving.

The solution:
You have 2 solutions:
1. Put your control in EditModePanel
<PublishingWebControls:EditModePanel runat=server id="EditModePanel1" PageDisplayMode="Display">
<------------Your Control --------------->
</PublishingWebControls:EditModePanel>

2. Hide your validators in edit mode:
WebPartManager wp = WebPartManager.GetCurrentWebPartManager(Page);
if(wp.DisplayMode == WebPartManager.BrowseDisplayMode)
{
yourvalidator.Visible = true;
}
else
{
yourvalidator.Visible = false;
}

Thursday, February 12, 2009

Deleting content Types in Sharepoint 2007 (The content type is in use)

Sometimes when you try to delete content type you faced error: The content type is in use.

Finding Lists/Libraries using the Content Type:
  1. We need a tool like the SharePoint Explorer for WSS 3.0 (needs to be run on the WSS server itself) to figure out what the SiteCollection ID is.
  2. We need the ContentTypeID of the content type we want to delete, the easiest way to get this is right out of the URL when you go to delete (or edit) the content type (Site Settings->Site Content Types->Click on your content type).

    Here's a sample URL.
    http://w2k3-tyler-virt/_layouts/ManageContentType.aspx? ctype=0x010700037B79D2DD41C24A8F55D82FC6B71FAC&Source=http%3A%2F% 2Fw2k3%2Dtyler%2Dvirt%2F%5Flayouts%2Fmngctype%2Easpx
    In this example the Content Type ID is 0x010700037B79D2DD41C24A8F55D82FC6B71FAC
  3. Now connect content database
    run stored procedure
    [proc_ListContentTypeInUse] [SiteCollectionId], [ContentTypeId]Or in out case:
    [proc_ListContentTypeInUse] 'D2F8C831-4CA7-41C0-8497-82F897B61B2B', 0x010700037B79D2DD41C24A8F55D82FC6B71FAC

or run query:
SELECT SiteId, sys.fn_varbintohexstr(ContentTypeId) AS ID, WebId, ListId, IsFieldId, Class
FROM ContentTypeUsageWHERE (sys.fn_varbintohexstr(ContentTypeId) LIKE '[ContentTypeID]%')

Remove these records and error appears when you try to delete will disappear.

Friday, November 21, 2008

Programmatically determine the display mode or edit mode of a website

You have a WCMS website and want to programmatically determine if the whole website is in display mode or edit mode. The namespace

using Microsoft.SharePoint.WebControls;

offers the SPControlMode enumeration with the members:
  • Display
  • Edit
  • Invalid
  • New

You can check the current mode by using the SPContext.Current object:
if (SPContext.Current.FormContext.FormMode == SPControlMode.Edit)
{
}

If you want implement a custom WebControl you can use Microsoft.SharePoint.WebControls.SPControlMode.Display to determine if your custom WebControl is in display or edit mode.

Custom Alert Template

To customize alerts template:
  1. Create a working copy of AlertTemplates.xml. File Alerttemplates.xml is located at: Local_Drive\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\XML directory.
    Note Do not modify Alerttemplates.xml itself. Make changes to a working copy.
  2. Edit the working copy that you just created.
    Use the stsadm command to read the changed templates into the database. STSADM -o updatealerttemplates -url -filename .
  3. Restart IIS.
    Note It may be necessary to restart SharePoint Timer Services.

To assign a custom alert template to a specific list:

Create a new custom template with a unique Name attribute in your working copy of AlertTemplates.xml (You can copy paste the entire section with Name SPAlertTemplateType.GenericList, change the name and modify the sections you want to). Modify the template as necessary. After restarting IIS, write object model code to set the list alert template.
SPAlertTemplateCollection ats = new SPAlertTemplateCollection((SPWebService)(WebApplication.Parent)); //give appropriate values for WebApplication
list.AlertTemplate = ats["name from above"];
list.Update();

More information about Alerts Customization here

Friday, November 7, 2008

Embedding JavaScript in SharePoint Pages

The best method to embed custom javascript in SharePoint pages is to create a .js file and then include it in the SharePoint Page. If you would like to include javascript functions in the onload event of a sharepoint page, use the _spBodyOnLoadFunctionNames array. Include the push method in your script with the title of your function. The function should not include parameters...

<script>
function runOnLoad(){

}
_spBodyOnLoadFunctionNames.push("runOnLoad");
</script>

You found _spBodyOnLoadFunctionNames in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\INIT.JS