Welcome to MSDN Blogs Sign in | Join | Help

How to create a custom view page with custom web part in the list definition , Bend it !!

The view pages for the list are created based on the “ViewPage.aspx” in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\Pages. The ViewPage.aspx inserts the DataFormWebpart to display the items in the View. Now What if you have a custom web part in which you want to display the items in the view and wants to insert the custom web part to the view page of all the view created for the list.

 

Following are the steps to achieve this requirement. So…. Get ready to bend the SharePoint without bending the rules J

 

1.    Copy the OOB “ViewPage.aspx” and place it in the same folder as “CustomViewPage.aspx”

2.    Create the custom web part which shows the items of the view with your custom approach.

3.    Create a feature to provision the “CustomViewpage.aspx” along with your custom web part.

4.    Create a custom list definition. In the schema.xml file of the definition for all the views mention the “SetupPath” to refer your “CustomViewPage.aspx”. With this step all the views mentioned in the list definition will use the “CustomViewPage.aspx” to create the view pages and as well all the views which you create after the creation of the list will use the “customViewPage.aspx” as the base page to create the view pages.

 

 

Step 1:

 

Just copy the OOB “ViewPage.aspx” and place it in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\Pages folder as “CustomViewPage.aspx”

 

Step 2:

 

Create the custom web part which shows the items of the view with your custom approach. Basically use the GetViewfromUrl(“Lists/<Listname>/<View_Name.aspx>”) method to get the view and then retrieve the items in the web part. The code snippet for the custom web part looks like follows :

 

SPList list = SPContext.Current.List;

String strViewName = <get the current view name from the URL>

SPView view = SPContext.Current.Web.GetViewFromUrl("Lists/list/ "+strViewName);

SPListItemCollection listItems = list.GetItems(view);

.
.

.

.

After getting the list items then do your custom approach of displaying the items.

 

Build the web part DLL and place it in the GAC.

 

Step 3:

 

Create a feature to provision the “CustomViewPage.aspx” along with your custom web part. By activating this feature the “Customviewpage.aspx” will be embedded with your custom web part.  The elements manifest file content looks like follows :

 

<?xml version="1.0" encoding="utf-8" ?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <Module  Name="CustomViewPage" Url="" Path="">

    <File Url="Pages/CustomViewPage.aspx" Type="Ghostable">

      <AllUsersWebPart WebPartZoneID="Main" WebPartOrder="1">

        <![CDATA[

                   <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">

                        <Assembly>CustomWebpartforView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e3483ddc8b0d437a</Assembly>

                        <TypeName> CustomWebpartforView.MyCustomview</TypeName>

                        <FrameType>None</FrameType>

                                                <IsVisible>true</IsVisible>

                        <Title>Custom Web part for View</Title>                                

                   </WebPart>

                   ]]>

      </AllUsersWebPart>

    </File>

  </Module>

</Elements>

 

Step 4:

 

Now the base custom view page is available along with the web part. Now how to integrate the custom view page with the list definition. Create a custom List definition and for all the views defined in the schema mention the “SetupPath” to use the “CustomViewPage.aspx”. Now the custom view page will be used as the base view page for all the views defined in the list definition and as well the views created later also will be using the “CustomViewpage.aspx” as the base page. The sample snippet for declaring the views inside the schema.xml is as follows :

 

<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,All_Tasks;" DefaultView="TRUE" MobileView="True" MobileDefaultView="False" SetupPath="pages\Customviewpage.aspx" ImageUrl="/_layouts/images/issues.png" Url="AllItems.aspx"><!-- _locID@DisplayName="camlidT8" _locComment=" " -->

 

 

Install and activate the feature of your custom list definition.

 

Now with all these steps, when you create a list based on this custom list definition then all the views created will be using the “CustomViewPage.aspx” to create the view pages and your custom web part will be rendered instead of the OOB dataformwebpart. The views which you will be creating after the creation of the List (Through UI, Through Object Model) will also use the “CustomViewpage.aspx” as the base page to create view pages.

 

Happy Customizing J

 

Posted by syed.er | 0 Comments

Word macros in the custom template for the document library disappears once document saved - SPS 2003 / MOSS

I have came across an interesting integration of Smart Documents with the SharePoint Document libraries through the custom template. I thought of sharing this with you guys. As long as you are using the OOB template.docx then we never worried about the document templates and its behavior but when we are using the custom templates with Macros on it then you will be encountering the issue on synchronizing the template with the client.

 

Whenever you add any custom Macros in the custom template of the document library then its mandatory to add two more default macros which are documented in the following article

http://msdn.microsoft.com/en-us/library/bb421314(office.11).aspx . But this article has a missing part which I covered in this post.

 

I have given the issue description and the resolution below and it applies for both SPS 2003 and MOSS and just the difference lies in the Office version.  

 

Problem Description

=================

 

When you create a document based on the custom template (with Macros in it) in your SharePoint document library, the macros in the document are disappears when you checked out and saved the document.

 

Root Cause

=========

 

The Reason for this behavior is that the document is referring the document template in the temporary internet files and the macros are no longer exists in those template.

 

Creating Custom template for WSS 2.0 Document Library

==========================================

 

When you open a document template from a Windows SharePoint Services document library, Word downloads a temporary copy of the template to the Temporary Internet Files folder on the local computer. After you close the document, Word deletes the local copy of the template. However, the document continues to reference the local file instead of the template located on the server. When we are creating custom template for SharePoint document library, we need to make sure that every time the user creates or opens the document ,the template from the server is update with the local template.

 

To achieve this, we need to create a XML expansion pack and make the document template as part of the XML expansion pack. Whenever the user creates or opens the document he will be asking to install the XML expansion pack and he will be downloading the document template from the server to user’s local machine.

 

Steps to create the XML expansion pack

============================

 

1.    The XML expansion pack consist the following files:

a.    A XML schema file

b.    A manifest file with information about the XML schema and the custom template

 

2.    Creating Schema for XML expansion pack:

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

 

The following code shows the structure for schema file for XML expansion pack. Create this file and save it as schema.xml

 

<?xml version="1.0" encoding="utf-8" ?>

<?mso-solutionextension URI="BarbiTest" manifestPath="http://sigr2-16a:6000/BarbiTest/Forms/manifest.xml"?>

<xs:schema targetNamespace="BarbiTest" xmlns:xs="http://www.w3.org/2001/XMLSchema"></xs:schema>

 

Note : Change the manifest path to your sharepoint site. The “URI” and the “targetnamespace” must be the same (Case sensitive ).

 

3.    Creating Manifest file for XML expansion pack:

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

 

The following code shows the structure for manifest file for XML expansion pack. Create this file and save it as manifest.xml

 

<manifest xmlns="http://schemas.microsoft.com/office/xmlexpansionpacks/2003">

  <version>1.0</version>

  <uri>BarbiTest</uri>

<?mso-solutionextension URI="BarbiTest" manifestPath="http://sigr2-16a:6000/BarbiTest/Forms/manifest.xml"?> // missing part in the article

  <solution>

    <solutionID>testSolution</solutionID>

    <type>other</type>

    <alias lcid="*">Template</alias>

    <file>

      <type>template</type>

      <version>1.0</version>

      <filePath>http://sigr2-16a:6000/Barbitest/Forms/custom.dot</filePath> (change the path to your sharepoint site)

      <templateID>{BAE06134-7C7E-4216-835F-6A0A63993919}</templateID>

    </file>

  </solution>

  <solution>

    <solutionID>testSolution-Schema</solutionID>

    <type>schema</type>

    <alias lcid="*">Template</alias>

    <file>

      <type>schema</type>

      <version>1.0</version>

      <filePath>http://sigr2-16a:6000/Barbitest/Forms/schema.xml</filePath> (change the path to your sharepoint site)

    </file>

  </solution>

 

          Note : Make sure that the URI and the namespace name are same as the schema.xml file created above

                                                                  

4.    Code Signing the XML expansion pack manifest file:

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

 

It is mandatory to code sign the XML expansion pack manifest file. The code signing tool for XML expansion pack comes with the Smart Document SDK. Download the smart document SDK from the following location  http://www.microsoft.com/downloads/details.aspx?FamilyId=24A557F7-EB06-4A2C-8F6C-2767B174126F&displaylang=en

           

The tool  XMLSign.exe will be installed in the following path C:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office 2003 Smart Document SDK\Tools. We need to create a  digital certificate to sign the manifest.xml file using this tool. After creating the digital certificate, Use the XMLSign tool through command prompt to code sign the manifest.xml file.

 

The following is the command for signing.  Xmlsign –cn <digital certificate name> <the manifest file with path>

 

 

Steps to create custom document template

=================================

 

1.    Create a word document and save it as document template (.dot)

2.    Add the following two macros to the template. These macros will make sure that the document refers the local template downloaded by the XML expansion pack and not from the temporary internet file folder.

 

Private Sub Document_New()

 

  ' Temporarily unlink this file from the template.

  ActiveDocument.AttachedTemplate = ""

 

  ' Then update the template (the UpdateTemplate function is a separate function).

  UpdateTemplate

 

End Sub

 

Private Sub Document_Open()

  ' Do nothing if the solution author opens the template directly.

  If (InStr(1, ActiveDocument.FullName, ".dot", vbTextCompare) = 0) Then

 

    ' Temporarily unlink this file from the template.

    ActiveDocument.AttachedTemplate = ""

 

    ' Update template.

    UpdateTemplate

 

  End If

End Sub

 

Sub UpdateTemplate()

 

  ' If the user has not downloaded the XML expansion pack at least once,

  ' this will fail; On Error Resume Next allows the code to continue.

  On Error Resume Next

 

  Dim strTemplatePath As String

 

  ' Get file name for local template - to do this, we need this path:

  ' %USERPROFILE%\Local Settings\Application Data\Microsoft\Schemas\

  ' <namespace>\<solutionId>\< templateFilename >.

  ' IMPORTANT:  You need to specify the <namespace>, <solutionId>,

  ' and < templateFilename > for your custom template.

 

  strTemplatePath = Environ("USERPROFILE") & _

    "\Local Settings\Application Data\Microsoft\Schemas\" & _

    "BarbiTest" & "\" & _

    "TestSolution" & "\" & _

    "custom.dot"

 

  ' Re-link document to local template.

  ActiveDocument.AttachedTemplate = strTemplatePath

End Sub

 

 

Place the Schema.xml , manifest.xml (code signed) and the custom template (with two important macros) to the Forms directory of your SharePoint document library.

 

Attaching the XML expansion pack with the Custom template

================================================

 

1.    Open the custom document template from the forms directory and go to toolsàTemplates and Add ins

2.    Select the XML Schema tab

3.    Add the schema.xml file from the Forms directory of SharePoint document library

4.    Select the XML expansion pack tab

5.    Add the manifest.xml from the Forms directory of SharePoint document library

6.    Make sure that all the schemas attached have been checked

7.    After attaching the schemas, go to toolsàOptions

8.    Select the security tab and select digital signature

9.    Select the Digital certificate which we created earlier and signed the template ( It is mandatory to digitally sign the template so that it will automatically run the Document_New and Document_Open Macros)

 

 

With these steps your custom template become Smart Document. When user creates a new document they will be asked to install the XML expansion pack , because the custom template is the part of the XML expansion pack. When the user installs the XML expansion pack the document template is downloaded from the server and installed in the user’s machine. Then every time when he opens the document the template will be referred from the following path  C:\Documents and Settings\<user>\Local Settings\Application Data\Microsoft\Schemas\<Namespace>\<solutionId> and not from the internet files folder. This makes the Macros alive even after the document is checked out and saved.

 

Hope this helps someone in future J

 

Posted by syed.er | 0 Comments

"Standard View, with Expanded Recurring Events" is missing in the custom calendar created from the custom calendar list definition. Bend it through custom ToolBar !!

I have came across another interesting issue with the custom calendar list definition last week.

 

As the SharePoint doesn’t consider your custom list definition as the “Events” type it doesn’t give you the option to create “Standard View, with Expanded Recurring Events" while creating the view for your custom calendar.

 

Again the SharePoint renders the option to create view based on the “List Type” and it renders the “Standard View, with Expanded Recurring Events" if the List template type is “106” but the template type of your list definition will be unique and not the “106” so the calendar created from your custom calendar list definition will not provide the option to create “Standard View, with Expanded Recurring Events".

 

This restriction is done in the “ViewType.aspx” application page under the layouts folder and you need to make changes in such a way that your custom calendar list type should be taken into consideration to render the option to create view with recurring events. Following is the content of the “ViewType.aspx” page and the changes to render the view for your custom list template is highlighted. Actually the view types are beautifully rendered in the OOB based on the list template type. The custom calendar list definition will be treated as a custom list and not as a calendar list so we need to make changes in several places as shown below : Replace the Feature GUID with the GUID of your Custom calendar list definition feature.

 

(Note : I have used the “TemplateFeatureID” property and rendering the view for the my custom calendar list template also. I am looking for some optimized way to achieve this. Because now you need to add one entry for every custom calendar list template you have)

 

<%@ Assembly Name="Microsoft.SharePoint.ApplicationPages, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%> <%@ Page Language="C#" Inherits="Microsoft.SharePoint.ApplicationPages.ViewTypesPage" MasterPageFile="~/_layouts/application.master"      %> <%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %> <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %>

<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Register Tagprefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, 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" %>

<%@ Register Tagprefix="Meetings" Namespace="Microsoft.SharePoint.Meetings" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

 

<script language="C#" runat="server">

SPSite spServer;

SPWeb spWeb;

SPList spList;

bool fHideStandardViewOption;

bool fHideGridViewOption;

bool fHideCalendarViewOption;

bool fHideRecursiveViewOption;

bool fHideDiscussionViewsOption;

bool fHideRichDbViewOption;

bool fHideGanttViewOption;

bool fHideCalendarViewForNonCalendarOption;

bool fColumnPosition;

string RecursiveViewTypeText;

string RecursiveViewTypeDescription;

string urlViewNew;

protected override void OnLoad(EventArgs e)

{

      base.OnLoad(e);

      spWeb = SPControl.GetContextWeb(Context);

      Microsoft.SharePoint.ApplicationPages.ListPageBase.ThrowIfNoListQueryString();

      spList = spWeb.Lists.GetList(new Guid(Request.QueryString.GetValues("List")[0]), true);

      PageTarget = spList;

      urlViewNew = "ViewNew.aspx?List=" +

            SPHttpUtility.UrlKeyValueEncode(Request.QueryString["List"]);

      string sourceParameter = Request.QueryString["Source"];

      if (!String.IsNullOrEmpty(sourceParameter))

      {

            urlViewNew += "&Source=" +

                  SPHttpUtility.HtmlUrlAttributeEncode(

                        SPHttpUtility.UrlKeyValueEncode(sourceParameter));

      }

      fHideGridViewOption = ListViewWebPart.RestrictedTemplateType(spList)

                                             || !spList.DoesUserHavePermissions(SPBasePermissions.UseClientIntegration);

    fHideStandardViewOption = (spList.BaseTemplate == SPListTemplateType.DiscussionBoard ||

                             spList.BaseTemplate == SPListTemplateType.Events);

      fHideDiscussionViewsOption = (spList.BaseTemplate != SPListTemplateType.DiscussionBoard);

    fHideCalendarViewOption = (spList.BaseTemplate != SPListTemplateType.Events);

      fHideCalendarViewForNonCalendarOption = (spList.BaseTemplate == SPListTemplateType.UserInformation);

      fHideRichDbViewOption = (spList.BaseTemplate == SPListTemplateType.UserInformation)

                                             || !spList.DoesUserHavePermissions(SPBasePermissions.UseClientIntegration);

      fHideGanttViewOption = (spList.BaseTemplate == SPListTemplateType.UserInformation);

      fColumnPosition=true;

}

private void FlipColumn()

{

      if (fColumnPosition)

            Response.Write("</table></td><td width=50%><table>");

      else

            Response.Write("</table></td></tr><tr><td wdith=50%><table>");

      fColumnPosition = (fColumnPosition) ? false : true;

}

</script>

<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">

      <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_pagetitle%>" EncodeMethod='HtmlEncode'/>

</asp:Content>

<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">

      <script>

      var navBarHelpOverrideKey = "SelectViewType";

      </script>

      <script language="javascript">

            var _spUseDefaultFocus = true;

            function _spBodyOnLoad()

            {

          if (browseris.ie5up && browseris.win32)

          {

              try

              {

                  var ExpDatabase = null;

                  var url = location.href;

                  ExpDatabase = new ActiveXObject("SharePoint.ExportDatabase");

                  if (ExpDatabase && ExpDatabase.IsDBProgramInstalled())

                  {

                  idAccViewRow.style.display = "inline";

                  idAccViewTitle.innerText = ExpDatabase.LinkTitle;

                  idAccViewCmt.innerText = ExpDatabase.LinkDescription;

                  if (url.toLowerCase().substr(0, 8) != 'https://')

                  {

                        document.all.idAccViewImg.src = ExpDatabase.LinkImageSrc;

                  }

                  document.all.idAccViewImg.alt = ExpDatabase.LinkDescription;

                  ExpDatabase = null;

                    return;

                  }

              }

              catch(e)

              {}

          }

            }

      </script>

</asp:Content>

<asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">

      <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_pagetitle%>" EncodeMethod='HtmlEncode'/>: <A ID="viewedit1" HREF=<%SPHttpUtility.AddQuote(SPHttpUtility.UrlPathEncode(spList.DefaultViewUrl,true),Response.Output);%>><%SPHttpUtility.HtmlEncode(spList.Title,Response.Output);%></A>

</asp:Content>

<asp:Content ContentPlaceHolderId="PlaceHolderPageImage" runat="server"/>

<asp:Content ContentPlaceHolderId="PlaceHolderPageDescription" runat="server">

      <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_pagedescription%>" EncodeMethod='HtmlEncode'/>

</asp:Content>

<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

            <table border="0" cellpadding="0" cellspacing="0" width="100%" style="font: small">

      <!-- Or choose a format -->

                        <tr><td width=100% colspan=2 valign=top>

                         <table width=100% border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                              <tr><td colspan=2 class="ms-linksectionheader" style="padding: 4px;" valign="top">

                                    <H3 class="ms-standardheader">

                                       <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_chooseformat%>" EncodeMethod='HtmlEncode'/>

                                    </H3>

                              </td></tr>

                              <tr><td><IMG SRC="/_layouts/images/blank.gif" width=1 height=1 alt=""></td></tr>

                         </table>

                         </td></tr>

</table>

<table>

 <tr>

  <td width=50%>

   <table>

      <!-- HTML View-->

<%

    if (!fHideStandardViewOption && spList.TemplateFeatureId != new Guid("FA77E3F5-6223-4de1-B25E-64659533F87A"))

      {

%>

                        <tr><td valign=top width="1%">

                        <table border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                           <tr><td>

                                    <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>' ID='onetCategoryHTMLimg' tabindex=-1>

                                     <img runat="server" border="0" alt="<%$Resources:wss,viewtype_idViewType2%>" src="/_layouts/images/ituser.gif" />

                                    </a>

                              </td><td width="4px"><IMG SRC="/_layouts/images/blank.gif" width=4 height=1 alt=""></td></tr>

                        </table>

                        </td>

                        <td class="ms-vb" width="99%" valign="top" ID="_spFocusHere">

                              <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>' ID='onetCategoryHTML'>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_idViewType1%>" EncodeMethod='HtmlEncode'/>

                              </a><br>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_idViewType2%>" EncodeMethod='HtmlEncode'/>

                        <br>&nbsp;

                  </td></tr>

<%

      FlipColumn();

      }

%>

      <!-- Discussion Board Views-->

<%

      if (!fHideDiscussionViewsOption)

      {

%>

            <!-- Subject View-->

                        <tr><td valign=top width="1%">

                        <table border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                           <tr><td>

                                    <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&BaseViewID=3' ID='onetCategoryHTMLimg' tabindex=-1>

                                    <img runat="server" border="0" alt="<%$Resources:wss,viewtype_subjectviewdesc%>" src="/_layouts/images/ituser.gif" />

                                    </a>

                              </td><td width="4px"><IMG SRC="/_layouts/images/blank.gif" width=4 height=1 alt=""></td></tr>

                        </table>

                        </td>

                        <td class="ms-vb" width="99%" valign="top" ID="_spFocusHere">

                              <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&BaseViewID=3' ID='onetCategoryHTML'>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_subjectview%>" EncodeMethod='HtmlEncode'/>

                              </a><br>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_subjectviewdesc%>" EncodeMethod='HtmlEncode'/>

                        <br>&nbsp;

                  </td></tr>

            <% FlipColumn(); %>

            <!-- Threaded View-->

                        <tr><td valign=top width="1%">

                        <table border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                           <tr><td>

                                    <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&BaseViewID=1' ID='onetCategoryHTMLimg' tabindex=-1>

                                    <img runat="server" border="0" alt="<%$Resources:wss,viewtype_threadedviewdesc%>" src="/_layouts/images/ituser.gif" />

                                    </a>

                              </td><td width="4px"><IMG SRC="/_layouts/images/blank.gif" width=4 height=1 alt=""></td></tr>

                        </table>

                        </td>

                        <td class="ms-vb" width="99%" valign="top" ID="_spFocusHere">

                              <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&BaseViewID=1' ID='onetCategoryHTML'>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_threadedview%>" EncodeMethod='HtmlEncode'/>

                              </a><br>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_threadedviewdesc%>" EncodeMethod='HtmlEncode'/>

                        <br>&nbsp;

                  </td></tr>

            <% FlipColumn(); %>

            <!-- Flat View-->

                        <tr><td valign=top width="1%">

                        <table border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                           <tr><td>

                                    <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&BaseViewID=2' ID='onetCategoryHTMLimg' tabindex=-1>

                                    <img runat="server" border="0" alt="<%$Resources:wss,viewtype_flatviewdesc%>" src="/_layouts/images/ituser.gif" />

                                    </a>

                              </td><td width="4px"><IMG SRC="/_layouts/images/blank.gif" width=4 height=1 alt=""></td></tr>

                        </table>

                        </td>

                        <td class="ms-vb" width="99%" valign="top" ID="_spFocusHere">

                              <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&BaseViewID=2' ID='onetCategoryHTML'>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_flatview%>" EncodeMethod='HtmlEncode'/>

                              </a><br>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_flatviewdesc%>" EncodeMethod='HtmlEncode'/>

                        <br>&nbsp;

                  </td></tr>

<%

             FlipColumn();

      }

%>

<%

    if (!fHideCalendarViewOption || spList.TemplateFeatureId == new Guid("FA77E3F5-6223-4de1-B25E-64659533F87A"))

      {

%>

      <!-- ALLITEMS View-->

                        <tr><td valign=top width="1%">

                        <table border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                           <tr><td>

                                    <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&BaseViewID=1' ID='onetCategoryHTMLimg' tabindex=-1>

                                    <img runat="server" border="0" alt="<%$Resources:wss,viewtype_idViewType2%>" src="/_layouts/images/ituser.gif" />

                                    </a>

                              </td><td width="4px"><IMG SRC="/_layouts/images/blank.gif" width=4 height=1 alt=""></td></tr>

                        </table>

                        </td>

                        <td class="ms-vb" width="99%" valign="top" ID="_spFocusHere">

                              <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&BaseViewID=1' ID='onetCategoryHTML'>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_idViewType1%>" EncodeMethod='HtmlEncode'/>

                              </a><br>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_idViewType2%>" EncodeMethod='HtmlEncode'/>

                        <br>&nbsp;

                  </td></tr>

      <%  FlipColumn(); %>

      <!-- RECURRENCE View-->

                        <tr><td valign=top width="1%">

                        <table border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                           <tr><td>

                                    <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&RecurrenceRowset=True&BaseViewID=3' ID='onetCategoryHTMLimg' tabindex=-1>

                                    <img runat="server" border="0" alt="<%$Resources:wss,viewtype_recviewdesc%>" src="/_layouts/images/ituser.gif" />

                                    </a>

                              </td><td width="4px"><IMG SRC="/_layouts/images/blank.gif" width=4 height=1 alt=""></td></tr>

                        </table>

                        </td>

                        <td class="ms-vb" width="99%" valign="top" ID="_spFocusHere">

                              <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&RecurrenceRowset=True&BaseViewID=3' ID='onetCategoryHTML'>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_idViewType7%>" EncodeMethod='HtmlEncode'/>

                              </a><br>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_recviewdesc%>" EncodeMethod='HtmlEncode'/>

                        <br>&nbsp;

                  </td></tr>

      <%  FlipColumn(); %>

      <!-- CALENDAR View for Calendar List-->

                        <tr><td valign=top width="1%">

                        <table border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                              <tr><td>

                                    <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&Calendar=True&BaseViewID=2' ID='onetCategoryCalendarimg' tabindex=-1>

                                    <img runat="server" border="0" alt="<%$Resources:wss,viewtype_calviewdesc%>" src="/_layouts/images/calview.gif" />

                                    </a>

                              </td><td width="4px"><IMG SRC="/_layouts/images/blank.gif" width=4 height=1 alt=""></td></tr>

                        </table>

                        </td>

                        <td class="ms-vb" width="99%" valign="top" ID="_spFocusHere">

                              <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&Calendar=True&BaseViewID=2' ID='onetCategoryCalendar'>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_calview%>" EncodeMethod='HtmlEncode'/>

                              </a><br>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_calviewdesc%>" EncodeMethod='HtmlEncode'/>

                        <br>&nbsp;

                  </td></tr>

                 

      <%  FlipColumn(); %>

<%

      }

%>

<%

      if (!fHideGridViewOption)

      {

%>

      <!-- Grid View-->

                        <tr><td valign=top width="1%">

                        <table border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                              <tr><td>

                                    <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&Grid=True' ID='onetCategoryGirdimg' tabindex=-1>

                                    <img runat="server" border="0" alt= "<%$Resources:wss,viewtype_datasheetviewdesc%>" src="/_layouts/images/grid.gif" />

                                    </a>

                              </td><td width="4px"><IMG SRC="/_layouts/images/blank.gif" width=4 height=1 alt=""></td></tr>

                        </table>

                        </td>

                        <td class="ms-vb" width="99%" valign="top" ID="_spFocusHere">

                              <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&Grid=True' ID='onetCategoryGrid'>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_datasheetview%>" EncodeMethod='HtmlEncode'/>

                              </a><br>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_datasheetviewdesc%>" EncodeMethod='HtmlEncode'/>

                        <br>&nbsp;

                  </td></tr>

       <%  FlipColumn(); %>

<%

      }

%>

   <!-- Calendar View-->

 <%

     if (!fHideStandardViewOption && !fHideCalendarViewForNonCalendarOption && spList.TemplateFeatureId != new Guid("FA77E3F5-6223-4de1-B25E-64659533F87A"))

      {

%>

      <!-- Calendar View for other lists except Calendar List-->

                        <tr><td valign=top width="1%">

                        <table border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                              <tr><td>

                                    <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&Calendar=True' ID='onetCategoryCalendarimg' tabindex=-1>

                                    <img runat="server" border="0" alt="<%$Resources:wss,viewtype_calviewdesc%>" src="/_layouts/images/calview.gif">

                                    </img></a>

                              </td><td width="4px"><IMG SRC="/_layouts/images/blank.gif" width=4 height=1 alt=""></td></tr>

                        </table>

                        </td>

                        <td class="ms-vb" width="99%" valign="top" ID="_spFocusHere">

                              <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&Calendar=True' ID='onetCategoryCalendar'>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_calview%>" EncodeMethod='HtmlEncode'/>

                              </a><br>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_calviewdesc%>" EncodeMethod='HtmlEncode'/>

                        <br>&nbsp;

                  </td></tr>

                  <!--<tr><td valign=top width="1%">

                        <table border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                           <tr><td>

                                    <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&RecurrenceRowset=True&BaseViewID=3' ID='A1' tabindex=-1>

                                    <img id="Img1" runat="server" border="0" alt="<%$Resources:wss,viewtype_recviewdesc%>" src="http://blogs.msdn.com/_layouts/images/ituser.gif" mce_src="http://blogs.msdn.com/_layouts/images/ituser.gif" />

                                    </a>

                              </td><td>&nbsp;</td></tr>

                        </table>

                        </td>

                        <td class="ms-vb" width="99%" valign="top" ID="Td1">

                              <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&RecurrenceRowset=True&BaseViewID=3' ID='A2'>

                              <SharePoint:EncodedLiteral ID="EncodedLiteral1" runat="server" text="<%$Resources:wss,viewtype_idViewType7%>" EncodeMethod='HtmlEncode'/>

                              </a><br>

                              <SharePoint:EncodedLiteral ID="EncodedLiteral2" runat="server" text="<%$Resources:wss,viewtype_recviewdesc%>" EncodeMethod='HtmlEncode'/>

                        <br>&nbsp;

                  </td></tr>-->

        <%  FlipColumn(); %>

<%

      }

%>

<%

      if (!fHideGanttViewOption)

      {

%>

      <!-- Gantt View-->

                        <tr><td valign=top width="1%">

                        <table border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                              <tr><td>

                                    <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&Gantt=True' ID='onetCategoryGanttimg' tabindex=-1>

                                    <img runat="server" border="0" alt="<%$Resources:wss,viewtype_ganttviewdescription%>" src="/_layouts/images/ganttview.gif">

                                    </img></a>

                              </td><td width="4px"><IMG SRC="/_layouts/images/blank.gif" width=4 height=1 alt=""></td></tr>

                        </table>

                        </td>

                        <td class="ms-vb" width="99%" valign="top" ID="_spFocusHere">

                              <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&Gantt=True' ID='onetCategoryGantt'>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_ganttview%>" EncodeMethod='HtmlEncode'/>

                              </a><br>

                              <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_ganttviewdescription%>" EncodeMethod='HtmlEncode'/>

                        <br>&nbsp;

                  </td></tr>

              <%  FlipColumn(); %>

<%

      }

%>

<%

      if (!fHideRichDbViewOption && spList.DefaultView != null)

      {

%>

      <!-- Rich DB View-->

                        <tr ID="idAccViewRow" style="display: none"><td valign=top width="1%">

                        <table border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                              <tr><td>

                              <A HREF="javascript:" onclick= <% SPHttpUtility.NoEncode("\"javaScript:ExportToDatabase('" + SPHttpUtility.EcmaScriptStringLiteralEncode(spWeb.Url) + "/_vti_bin/owssvr.dll', '" + spList.ID.ToString("B").ToUpperInvariant() + "', '" + spList.DefaultView.ID.ToString("B").ToUpperInvariant() + "', 'true');javascript:return false;\"",Response.Output); %> tabindex=-1>

                                    <img ID="idAccViewImg" src="/_layouts/images/grid.gif" border="0">

                                    </img></A>

                              </td><td width="4px"><IMG SRC="/_layouts/images/blank.gif" width=4 height=1 alt=""></td></tr>

                        </table>

                        </td>

                        <td class="ms-vb" width="99%" valign="top" ID="_spFocusHere">

                              <A ID="idAccViewTitle" HREF="javascript:" onclick= <% SPHttpUtility.NoEncode("\"javaScript:ExportToDatabase('" + SPHttpUtility.EcmaScriptStringLiteralEncode(spWeb.Url) + "/_vti_bin/owssvr.dll', '" + spList.ID.ToString("B").ToUpperInvariant() + "', '" + spList.DefaultView.ID.ToString("B").ToUpperInvariant() + "', 'true');javascript:return false;\"",Response.Output); %> >

                              </A><br>

                              <span ID="idAccViewCmt"></span>

                        <br>&nbsp;

                  </td></tr>

<%

      }

%>

               </table>

              </td>

             </tr>

</table>

      <!-- Create From Existing View -->

                  <table width="100%" border=0>

                        <tr><td width=100% colspan=2 valign=top>

                        <INPUT name="List" type="hidden" value=<%SPHttpUtility.UrlKeyValueEncode(Request.QueryString["List"], Response.Output);%>>

                        <table width=100% border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                              <tr><td  colspan=2 class="ms-linksectionheader" style="padding: 4px;" valign="top">

                                 <H3 class="ms-standardheader">

                                      <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_startfromexisting%>" EncodeMethod='HtmlEncode'/>

                                 </H3>

                              </td></tr>

                        </table>

                        <table style="margin: 2px 5px 0px 5px;" cellspacing=0 cellpadding=0>

<%

                                          foreach (SPView view in spList.Views)

                                          {

                                                if (view.Hidden || view.EditorModified || view.ReadOnlyView || String.IsNullOrEmpty(view.Title))

                                                      continue;

%>

                                                <tr>

                                                 <td valign="top" class="ms-descriptiontext" style="padding-top:5px;">

                                                  <IMG src="/_layouts/images/setrect.gif" width=5px height=5px alt=''>&nbsp;

                                                 </td>

                                                 <td width=100% class="ms-descriptiontext" style="padding-top:7px;padding-left: 3px;">

                                                      <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&View=<%SPHttpUtility.UrlKeyValueEncode(view.ID.ToString(), Response.Output);%>'> <% SPHttpUtility.HtmlEncode(view.Title,Response.Output); %> </a>

                                                 </td>

                                                </tr>

<%

                                          }

%>

                        </table>

                        <br>

                        </td>

                        </tr>

                    </table>

      <!-- Create From View Template -->

<%

      System.Collections.Generic.ICollection<SPView> uninstantiatedViews = GetUncustomizedViewsWhichAreNotInstantiated(spList);

      if (uninstantiatedViews.Count > 0)

      {

%>

                    <table width="100%">

                        <tr><td width=100% colspan=2 valign=top>

                        <INPUT name="List" type="hidden" value=<%SPHttpUtility.UrlKeyValueEncode(Request.QueryString["List"], Response.Output);%>>

                        <table width=100% border=0 cellspacing=0 cellpadding=0 style="padding-top:2px">

                              <tr><td  colspan=2 class="ms-linksectionheader" style="padding: 4px;" valign="top">

                                     <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,viewtype_startfromtemplate%>" EncodeMethod='HtmlEncode'/>

                              </td></tr>

                        </table>

                        <table style="margin: 2px 5px 0px 5px;" cellspacing=0 cellpadding=0>

<%

                                          System.Collections.Generic.ICollection<SPView> uncustomizedViews = GetUncustomizedViews(spList);

                                          foreach (SPView view in uninstantiatedViews)

                                          {

%>

                                                <tr>

                                                 <td valign="top" class="ms-descriptiontext" style="padding-top:5px;">

                                                  <IMG src="/_layouts/images/setrect.gif" width=5px height=5px alt=''>&nbsp;

                                                 </td>

                                                 <td width=100% class="ms-descriptiontext" style="padding-top:7px;padding-left: 3px;">

                                                      <a href='<%SPHttpUtility.NoEncode(urlViewNew, Response.Output);%>&BaseViewID=<%SPHttpUtility.UrlKeyValueEncode(view.BaseViewID, Response.Output);%>'> <% SPHttpUtility.HtmlEncode(view.Title,Response.Output); %> </a>

                                                 </td>

                                                </tr>

<%

                                          }

%>

                        </table>

                        </td>

                        </tr>

                    </table>

<%

      }

%>

</asp:Content>

 

Save the changes and you can find that the standard view with recurring events option is rendered in your custom calendar created from the custom calendar list definition. So bending the SharePoint without bending the rules starts here J … Yes you cannot make changes to the OOB “ViewType.aspx” page directly as it is not supported…

 

So take a copy of the OOB “ViewType.aspx” page and make the above shown changes and save it in the same “Layouts” folder say as “CustomViewType.aspx” page. Koool !! We have successfully created the “CustomviewType.aspx” page… But creating the view in the SharePoint calendars will not navigate you to the “CustomViewType.aspx” and by default they will navigate you to OOB “ViewType.aspx” page.

 

Following are three places where you need to do customization so that you can use the “CustomViewType.aspx” to create the view for the calendar created from your custom calendar list definition:

 

1.    “Create View” menu item of the “Settings Menu” in the calendar toolbar.

 

2.    “Create View” menu item of the “ListView Selector” in the calendar toolbar.

 

3.    “Create View” link of the “ListEdit.aspx” application page. We cannot make changes to the OOB “ListEdit.aspx” page so take a copy of the “ListEdit.aspx” and make the changes to navigate to the “CustomViewType.aspx” page and save it as say “CustomListEdit.aspx” page. So again the customization lies in customizing the “List Settings” menu item in the Settings Menu to navigate to the “CustomListEdit.aspx” page.

 

Customizing the “Settings Menu”  in the calendar View toolbar to change the Navigation of “Create View” and “List Settings” menu item :

 

1.    To change the Navigate URL of the “Create View” menu item of the “Settings Menu” we need to override the “SetMenuItemProperties” method of the Microsoft.SharePoint.WebControls.SettingsMenu Type. Create your own “SettingsMenu” web control and override the “SetMenuItemProperties” as shown below. The below highlighted snippets shows the changes to navigate to the custom page for “Create View” and “List Settings” menu item.

 

 

public class SettingsMenuCalendar:SettingsMenu 

    {

        protected override void SetMenuItemProperties()

        {

          

            string str;

            base.MenuTemplateControl.LargeIconMode = true;

           // SPHttpUtility.UrlKeyValueEncode(base.RenderContext.RootFolderUrl);

            string str2 = "&Source=" + SPHttpUtility.UrlKeyValueEncode(SPHttpUtility.UrlPathEncode(SPUtility.GetFullUrl(this.Web.Site, HttpContext.Current.Request.RawUrl), true));

            MenuItemTemplate menuItem = base.GetMenuItem("AddColumn");

            if (menuItem != null)

            {

                str = WebLayoutsPath + "fldNew.aspx?List=" + SPHttpUtility.UrlKeyValueEncode(this.List.ID.ToString("B")) + str2;

                menuItem.ClientOnClickNavigateUrl = str;

            }

            menuItem = base.GetMenuItem("AddQuestions");

            if (menuItem != null)

            {

                str = WebLayoutsPath + "qstNew.aspx?List=" + SPHttpUtility.UrlKeyValueEncode(this.List.ID.ToString("B")) + str2;

                menuItem.ClientOnClickNavigateUrl = str;

            }

            menuItem = base.GetMenuItem("AddView");

            if (menuItem != null)

            {

                str = WebLayoutsPath + "CustomViewType.aspx?List=" + SPHttpUtility.UrlKeyValueEncode(this.List.ID.ToString("B")) + str2;

                menuItem.ClientOnClickNavigateUrl = str;

            }

            menuItem = base.GetMenuItem("ListSettings");

            if (menuItem != null)

            {

                if (this.List.BaseType != SPBaseType.Survey)

                {

                    str = WebLayoutsPath + "Customlistedit.aspx?List=" + SPHttpUtility.UrlKeyValueEncode(this.List.ID.ToString("B"));

                }

                else

                {

                    str = WebLayoutsPath + "survedit.aspx?List=" + SPHttpUtility.UrlKeyValueEncode(this.List.ID.ToString("B"));

                }

                menuItem.ClientOnClickNavigateUrl = str;

                menuItem.Text = SPUtility.FormatStringWithListType(SPResource.GetString("ToolBarMenuItemSettings", new object[0]), this.List, false);

                if (string.IsNullOrEmpty(menuItem.Description))

                {

                    menuItem.Description = SPUtility.FormatStringWithListType(SPResource.GetString("ToolBarMenuItemSettingsDescription", new object[0]), this.List, true);

                }

            }

            base.MenuControl.ID = "ListSettingsMenu";

            base.MenuControl.UseShortId = true;

 

 

        }

// WebLayoutsPath is used in the above method to get the site relative “Layouts” path correctly

        internal string WebLayoutsPath

        {

            get

            {

                string parentWebUrl = this.List.ParentWebUrl;

                if (!parentWebUrl.EndsWith("/"))

                {

                    parentWebUrl = parentWebUrl + "/";

                }

                return (parentWebUrl + "_layouts/");

            }

        }

 

    }

 

2.    Build the DLL. We will see later that how we can render the custom “SettingsMenu” web control instead of OOB control to the calendar list toolbar.

 

 

Customizing the “ListView Selector” in the calendar view toolbar:

 

1.    To change the Navigate URL of the “Create View” menu item of the “ListView Selector Menu” we need to override the “DefaultTemplateName” property of the Microsoft.SharePoint.WebControls.ListViewSelector Type. Create your own “ListViewSelector” web control and override the “DefaultTemplateName” as shown below.

 

public class CustomListViewSelector : ListViewSelector

    {

        protected override string DefaultTemplateName

        {

            get

            {

                return "CustomViewSelector";

            }

        }

    }

 

2.    The above mentioned code just changes the name of the rendering template name but the control which renders the View Selector in the toolbar is the Microsoft.SharePoint.WebControls.ViewSelectorMenu. We need to override the “SetMenuItemProperties”  method of the “ViewSelectorMenu” type as shown below to change the navigation of “Create view” menu item.

 

public class CustomViewSelectormenu : ViewSelectorMenu

    {

        protected override void SetMenuItemProperties()

        {

            //base.SetMenuItemProperties();

           

            string str;

            base.MenuTemplateControl.LargeIconMode = true;

            // SPHttpUtility.UrlKeyValueEncode(base.RenderContext.RootFolderUrl);

            string str2 = "&Source=" + SPHttpUtility.UrlKeyValueEncode(SPHttpUtility.UrlPathEncode(SPUtility.GetFullUrl(this.Web.Site, HttpContext.Current.Request.RawUrl), true));

            MenuItemTemplate menuItem = base.GetMenuItem("CreateView");

            if (menuItem != null)

            {

                str = WebLayoutsPath + "CustomViewType.aspx?List=" + SPHttpUtility.UrlKeyValueEncode(this.List.ID.ToString("B")) + str2;

                menuItem.ClientOnClickNavigateUrl = str;

              

            }

        }

 

        internal string WebLayoutsPath

        {

            get

            {

                string parentWebUrl = this.List.ParentWebUrl;

                if (!parentWebUrl.EndsWith("/"))

                {

                    parentWebUrl = parentWebUrl + "/";

                }

                return (parentWebUrl + "_layouts/");

            }

        }

    }

 

3.    Build the DLL and place it in the GAC. You can keep all the above shown classes in the same project or in different, for example here I have written all the classes in the same assembly.

 

 

Now we will have a look on how to render the custom web controls which we created instead of the OOB web controls to the Custom calendar list template.

 

Creating Custom “defaulttemplates.ascx” to render the Custom SettingsMenu and the ViewSelectorMenu

 

1.    Create a user control in the Control Templates folder and add the custom rendering template to render your custom control as follows. You can take a look on this blog post on customizing the List Toolbar template:

 

a.    In the custom defaulttemplates.ascx control add all the reference to the required DLL’s including your custom DLL created for the custom “SettingsMenu” and the custom “ViewSelectorMenu”

 

<%@ Control Language="C#"   AutoEventWireup="false" %>

<%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>

<%@Register TagPrefix="CustomSettingsMenu" Assembly="CustomSettingsMenu, Version=1.0.0.0, Culture=neutral, PublicKeyToken=031d0c8d7c05496f" namespace="CustomSettingsMenu"%>

<%@Register TagPrefix="SPHttpUtility" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Utilities"%>

<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>

<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>

 

b.    The Following rendering template is to render the “CustomViewSelector” template which holds the Custom “ViewSelectorMenu”.

 

<SharePoint:RenderingTemplate ID="CustomViewSelector" runat="server">

      <Template>

            <table border="0" cellpadding="0" cellspacing="0" style='margin-right: 4px'>

            <tr>

               <td nowrap class="ms-listheaderlabel"><SharePoint:EncodedLiteral ID="EncodedLiteral1" runat="server" text="<%$Resources:wss,view_selector_view%>" EncodeMethod='HtmlEncode'/>&nbsp;</td>

               <td nowrap class="ms-viewselector" id="onetViewSelector" onmouseover="this.className='ms-viewselectorhover'" onmouseout="this.className='ms-viewselector'" runat="server">

                        <CustomSettingsMenu:CustomViewSelectorMenu MenuAlignment="Right" AlignToParent="true" runat="server" id="ViewSelectorMenu1" />

                  </td>

            </tr>

            </table>

      </Template>

</SharePoint:RenderingTemplate>

 

c.    The following rendering template is to render the Custom “SettingsMenu” and the Custom “ListViewSelector” toolbar. This template will be used by the each views of the custom calendar list definition to render the toolbar.

 

<SharePoint:RenderingTemplate ID="CalendarViewToolbar" runat="server">

      <Template>

            <wssuc:ToolBar CssClass="ms-menutoolbar" EnableViewState="false" id="toolBarTbl" ButtonSeparator="<img src='/_layouts/images/blank.gif' alt=''>" RightButtonSeparator="&nbsp;&nbsp;" runat="server">

                  <Template_Buttons>

                        <SharePoint:NewMenu ID="NewMenu1" AccessKey="<%$Resources:wss,tb_NewMenu_AK%>" runat="server" />

                        <SharePoint:ActionsMenu ID="ActionsMenu1" AccessKey="<%$Resources:wss,tb_ActionsMenu_AK%>" runat="server" TemplateName="ToolbarActionsMenu" />

                        <CustomSettingsMenu:SettingsMenuCalendar ID="SettingsMenu1" AccessKey="<%$Resources:wss,tb_SettingsMenu_AK%>" runat="server" />

                  </Template_Buttons>

                  <Template_RightButtons>

                          <SharePoint:PagingButton ID="PagingButton1" runat="server"/>

                          <CustomSettingsMenu:CustomListViewSelector ID="ListViewSelector1" runat="server"/>

                         

                  </Template_RightButtons>

            </wssuc:ToolBar>

      </Template>

</SharePoint:RenderingTemplate>

 

 

d.    The final step is to change the “Schema.xml” of the custom calendar list definition to use the above mentioned “CalendarViewToolbar” template to render the view toolbar. Open the schema.xml file of the custom calendar list definition and set the “ToolbarTemplate” property of every view as shown below. Following is the example snippet for the “All Events” view make this change to every view in the schema.

 

<View BaseViewID="1" Type="HTML" ToolbarTemplate="CalendarViewToolbar"  WebPartZoneID="Main" DisplayName="$Resources:core,userinfo_schema_alleventsview;" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/events.png" Url="AllItems.aspx" DefaultBaseView="TRUE">

 

 

That’s all …… with all these changes you have successfully implemented the Standard view with Recurring events to your custom calendar list definition in the supported way by overriding the “SettingsMenu” and the “ViewSelectorMenu” in the supported way. I have attached all the required files and the DLL’s required to implement this requirement.

 

After all the changes in place make sure that you do an IISRESET J

 

                               

                                                                                                            Happy Customizing

Posted by syed.er | 0 Comments

SPSearch.asmx doesn’t return results when integrated with Search server 2008

Last week I came across a very weird issue that the client application for Search using the SPSearch.asmx web service is not returning any result in WSS 3.0 environment. I investigated the client application and the Query Packet built within it and for my bad everything is perfect and I couldn’t find any breakthrough or the root cause which is causing it. The OOB search is working fine and giving me the result. During the investigation I had the turning point in this mystery story and the truth is that the WSS 3.0 environment is integrated with the “Search Server 2008”… ALAS !!!

 

WSS 3.0 only installation has the “SPSearch.asmx” Web Service to use the Search and query against the Windows SharePoint Search Service Engine.

 

But When the Search Server 2008 is integrated with the WSS 3.0 then the WSS 3.0 will start using the Enterprise Office Search Service and all the DLL’s and the services related to it will be available with the WSS 3.0 Environment. As well the “Search.asmx” web service is also installed which uses the Enterprise Office Search Service.

 

When you develop client application is such a environment (WSS 3.0 integrated with the Search Server 2008) for the Search please make sure that you are adding reference to the “Search.asmx” Web Service and not to the “SPSearch.asmx” Web service. I just changed the reference to the "Search.asmx" and hurray the search started returing the results.

 

If you use the “SPSearch.asmx” web service by just remembering the WSS 3.0 environment then you will not get any results returned as the WSS 3.0 environment integrated with the Search Server 2008 will be using the “Enterprise Office Search Service”.

 

So if you have a standalone WSS 3.0 installation then you need to use the “SPSearch.asmx” web service for querying in the client application ( As well the “Search.asmx” will not be available with the Standalone WSS 3.0 installation). If you have the search server 2008 configured with the WSS 3.0 then you need to work with the “Search.asmx” web service for querying in the client application.

 

 

Hope this helps someone to come out of this frustration quicker than me J

Posted by syed.er | 0 Comments

How to hide the new menu folder option from document library by default to all the document library instances

One of our customer came with a requirement of hiding the new menu folder option from the document library instances by default.

 

This can be done through UI as well but customer don't want to do this manually through UI. By default folder creation is enabled in UI.

 

The New folder button appears because of "Folder" Content type (0X0120) associated with the document library definition and as well the "FolderCreation" attribute is set to TRUE by default in the document library definition.

 

If we create a new custom document library definition and set the "FolderCreation" attribute to False in the schema for the "List" element then we can hide the "New Folder" creation in the document libraries. Create a custom document library definition by copying the OOB document library definition and  set the "FolderCreation" attribute to False in the schema for the "List" element. This will completely hide the New Folder option under New menu and as well you can check in the UI that "Folder" creation is set to "No" by default.

 

<?xml version="1.0" encoding="utf-8"?>

<List xmlns:ows="Microsoft SharePoint" Title="$Resources:shareddocuments_Title;" Direction="$Resources:Direction;" Url="Shared Documents" BaseType="1" FolderCreation=”False”>

  <MetaData>

    <ContentTypes>

      <ContentTypeRef ID="0x0101">

        <Folder TargetName="Forms/Document" />

      </ContentTypeRef>

      <ContentTypeRef ID="0x0120" />

    </ContentTypes

 

      .

      .

      .

Install and activate the custom document library definition and create a new document library instance from the custom document library definition. Now you can find that the document library instances created from the custom document library definition are not having the “New Folder” option under the New menu in the toolbar. If you browse to the document library setting you can find that the folder creation option is set to false by default and if required you can enable it by changing the settings.

Note : Don't remove the folder content type from the document library definition or don't set the "FolderCreation" attribute in the "ListTemplate" element in the element manifest. Because it completely removes the folder creation and folder content type from the doc lib definition which can cause some problem in future. Its always better to override this property directly in the schema rather than in the definition so that we can keep the folder feature and just hide it.

Posted by syed.er | 0 Comments