Through this blog, it is my effort to share experiences with the community and make the journey enjoyable.

Sunday, October 05, 2008

SharePoint Custom View Actions

Posted a new article on CodeProject to add two new actions on Toolbar for SharePoint lists.

http://www.codeproject.com/KB/sharepoint/customviewactions.aspx.


Although, both of these functionalities are available out-of-box, but having these links on the toolbar itself, improves user productivity.

With respect to technical implementation -

  1. For action 'Creating new view, replicating existing view' : Used out-of-box application page 'viewnew.aspx'.
  2. For action 'Delete current view' : Added new application page and deleted the view using SharePoint Object model. However, discovered a issue with SharePoint object model. While deleting the view with object model, there is no check for default view. It deletes the default view also, which removes the list from the Quick Launch bar. Out-of-box Microsoft functionality, is making 'Delete' button visible true or false, on the frontend for ViewEdit.aspx, but it is not checked at the API level.

    For this custom action, I have checked for the default view, and changed the 'Action' Text accordingly.

Share:

Wednesday, October 01, 2008

Risks Matrix for SharePoint Projects

Very helpful document on Risk Management for SharePoint Project - http://thorprojects.com/files/sharepointcommonrisksforvariousprojecttypes.pdf

Some important Risk Types -

  • Bad Expectations
  • Poor Terms definition
  • Poor Understanding
  • No value proposition
  • No compelling reason
  • No Launch
  • Poor Adoption

    SharePoint Internet Sites -

  • Major Risks are poor understanding, no Launch & poor Understanding.
  • The greatest issue with Internet site is how SharePoint processes requests and how it will fit into the environment. While SharePoint is capable of being used in Internet applications, it's not designed for this purpose. It will exhibit limitations when used in the anonymous authentication environment of the Internet.
Share:

Tuesday, September 30, 2008

Custom DataSheet View Using ListNet ActiveX Control


Introduction -

SharePoint DataSheet Page is used for editing lists in multiple record grid format. DataSheet view uses ListNet control, which is an ActiveX control. This control is also works in conjunction with the ListViewWebPart class to provide users with a dataview for editing lists in Microsoft Windows SharePoint Services.

ListNet control is defined in the STSLIST.DLL file, a dynamic-link library (DLL) that is installed on the client during 2007 Office system setup in the Local_Drive:\Program Files\Microsoft Office\OFFICE12 directory.

Analyzing out-of-box 'Edit in DataGrid' Page -

On clicking on 'Edit in DataGrid', redirection to 'AllItems.aspx' (~site/{DocLib}Forms/AllItems.aspx?ShowInGrid=True&View={ViewGuid}) happens.

In summary, looking at the source of the page, it contains Script tag, which calls Javascript function, RenderActiveX. RenderActiveX has the object tag with class id={65BCBEE4-7728-41a0-97BE-14E1CAE36AAE}.

Parameters which are set on the page, to render the ActiveX are - ListName, ViewGuid, ListWeb. ListData, ViewSchema, ListSchema.

In summary, below is the script tag -
<SCRIPT>RenderActiveX("<OBJECT id='STSListControlWPQ2' name='STSListControlWPQ2' classid=CLSID:65BCBEE4-7728-41a0-97BE-14E1CAE36AAE PARAM NAME='ListName' VALUE='{ListID} PARAM NAME=ViewGuid VALUE={ViewID} PARAM NAME=ListWeb VALUE={WebUrl} PARAM NAME='ListData' VALUE={ListData} PARAM NAME=ViewSchema VALUE={ViewSchema} PARAM NAME='ListSchema' VALUE={ListSchema} PARAM NAME='ControlName' VALUE='STSListControlWPQ2' > </OBJECT>");</SCRIPT>

Custom Application Page using ListNet ActiveX Page -
Below is some of the code snippet used in the application page. Application Page is passed two query parameters ListId and WebId, to create dynamic view for the list in the web.


<script runat="server">
SPWeb web;
SPList list;
string ListData, ViewSchema, ListSchema;

protected override void OnLoad(EventArgs e)
{
//Reading ListId querstring parameter
Guid listGuid = new Guid(Request.QueryString.Get("ListId"));

//Reading WebId querstring paramter
Guid webGuid = new Guid(Request.QueryString.Get("WebId"));

SPSite site = SPContext.Current.Site;
web = site.OpenWeb(webGuid);
list = web.Lists[listGuid];

//Custom string functions, STSHtmlEncode & STSScriptEncode to encode the string
ListData = STSScriptEncode(STSHtmlEncode(list.Items.Xml));
ViewSchema = STSScriptEncode(STSHtmlEncode(list.DefaultView.SchemaXml));
ListSchema = STSScriptEncode(STSHtmlEncode(list.SchemaXml));

}
</script>

<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<SCRIPT>RenderActiveX("\u003cOBJECT id=\u0022STSListControlWPQ2\u0022 name=\u0022STSListControlWPQ2\u0022 classid=CLSID:65BCBEE4-7728-41a0-97BE-14E1CAE36AAE width=\u002299\u0025\u0022 tabindex=\u00221\u0022\u003e\u003cPARAM NAME=\u0022ListName\u0022 VALUE=\u0022{<%=list.ID.ToString()%>}\u0022\u003e\u003cPARAM NAME=\u0022ViewGuid\u0022 VALUE=\u0022{<%=list.DefaultView.ID.ToString()%>}\u0022\u003e\u003cPARAM NAME=\u0022ListWeb\u0022 VALUE=\u0022<%=web.Url%>\u002f_vti_bin\u0022\u003e\u003cPARAM NAME=\u0022ListData\u0022 VALUE=\u0022<%=ListData%>\u0022\u003e\u003cPARAM NAME=\u0022ViewSchema\u0022 VALUE=\u0022<%=ViewSchema%>\u0022\u003e\u003cPARAM NAME=\u0022ListSchema\u0022 VALUE=\u0022<%=ListSchema%>\u0022\u003e\u003cPARAM NAME=\u0022ControlName\u0022 VALUE=\u0022STSListControlWPQ2\u0022\u003e\u003cp class=ms-descriptiontext\u003eThe Datasheet view of this list cannot be displayed. Please wait while the page is redirected to Standard view. If your list does not appear in a few moments, \u003cA onclick=\u0022javascript:GCNavigateToNonGridPage\u0028\u0029; javascript:return false;\u0022 href=\u0022?ShowInGrid=False\u0022 target=_self\u003eopen the list in Standard view\u003c\u002fA\u003e\u003c\u002fp\u003e\u003c\u002fOBJECT\u003e");
</SCRIPT>

<asp:Content>

Share:

Monday, September 29, 2008

Switching between WebPart Pages Modes

Frequently, need for switching between different modes in WebPart page programmatically is felt. For this we have used using various SharePoint JavaScript functions like MSOTlPn_ShowToolPaneWrapper, MSOLayout_ToggleLayoutMode etc. have been used in the past.New approach for the switching between WebPart modes would be to use WebPartManager DisplayModes collection and setting DisplayMode.Below attached sample webpart code, achieves the same. When you load the page in a browser, Display Mode drop-down list control is populated with display modes and is used to switch to different display modes. To edit controls, select Edit in the drop-down list control. When you are finished, select Browse in the Display Mode drop-down list control to return the page to a normal view. To add controls to the page, switch to catalog mode.

using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

namespace SPUtil
{

[Guid("68e96c2c-c788-4cf3-834a-9a7ec1ba0d9c")]
public class EditModeSwitchWebPart : System.Web.UI.WebControls.WebParts.WebPart
{
DropDownList dropdownDisplayMode;
protected override void CreateChildControls()
{
base.CreateChildControls();
dropdownDisplayMode = new DropDownList();
dropdownDisplayMode.AutoPostBack = true;
dropdownDisplayMode.SelectedIndexChanged += new EventHandler(dropdownDisplayMode_SelectedIndexChanged);

foreach (WebPartDisplayMode wpDisplayMode in WebPartManager.DisplayModes)
{
WebPartDisplayMode enabledWpDisplayMode = WebPartManager.SupportedDisplayModes[wpDisplayMode.Name];
if (enabledWpDisplayMode != null)
dropdownDisplayMode.Items.Add(enabledWpDisplayMode.Name);
}
Controls.Add(dropdownDisplayMode);
}

void dropdownDisplayMode_SelectedIndexChanged(object sender, EventArgs e)
{
if(this.dropdownDisplayMode.SelectedItem != null)
this.WebPartManager.DisplayMode = WebPartManager.DisplayModes[dropdownDisplayMode.SelectedValue];
}
}
}
Share:

Wednesday, August 20, 2008

Redirecting to custom application page, after uploading documents

Overview -
SharePoint Upload.aspx page is used for uploading documents from the document libraries and other lists. Upload.aspx is called, by passing various Query String parameters like ListId, Source, MultipleUpload etc. MultipleUpload parameter is used to display controls for single or multiple file upload. After uploading the documents, code redirection happens to AllItems.aspx or EditForm.aspx, based on scenarios. Since, redirection happens in code behind, creating custom application page to perform upload function and redirecting, serves the purpose. To start with, approach looks like, lot of development effort. However, it is very simple, since we are reusing the functionality provided in upload.aspx. This enables you to inject specific business rules and processes for adding files to the library. This also enables to write specific business processes as well custom file processing.

Code
Creation of custom aspx page with code behind library. Instead of creating a completely new Upload page, you will derive from the existing Upload page and functionality and modifying the functionality you want. To do this, you reference the Microsoft.SharePoint and Microsoft.SharePoint.ApplicationPages assemblies in your project. Then you create a class that derives from the Microsoft.SharePoint.ApplicationPages.UploadPage class. This class uses the Microsoft.SharePoint and Microsoft.SharePoint.ApplicationPages namespaces. The functionality that we want is redirect the users to custom application page.


C# Code -
namespace UploadRedirect
{
public class CustomUpload : Microsoft.SharePoint.ApplicationPages.UploadPage
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
//Set the literal control text to redirect page.
this.ConfirmationURL.Text = { Complete Url to the Redirect Page }

}
}
}

Creating the ASPX Page –
Create new custom aspx page, based on Upload.aspx from Layouts directory. Add the reference of above creating assembly on the top of custom aspx page. Rest of the content remains the same. Deploy the assembly in Global Assembly Cache and custom upload aspx page in layouts directory. Test the page, by passing the same query string parameters as being passed in upload.aspx.


Redirecting the User to the New Upload Page -
Change the links for Upload and Multiple Upload in the Document Library. There can be different approaches for the same. Custom Document Library Template with the path to custom upload page, would be one of them. Using Javascript of overriding the links, can be another.

References -
Microsoft MSDN Article -
Preventing Record Modification but Allowing Metadata Modification by Overriding the Upload Page in Windows SharePoint Services 3.0



Share:

Search This Blog

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway. All posts are provided "AS IS" with no warranties, and confers no rights. In addition, my thoughts and opinions often change, and as a weblog is intended to provide a semi-permanent point in time snapshot you should not consider out of date posts to reflect my current thoughts and opinions.

Popular Posts

Total Pageviews