Wednesday, December 9, 2009
Set Item level permission in Sharepoint Document Library
Code snippet
using (SPSite spSiteObje = new SPSite("http://SiteColName/Subsite"))
{
using (SPWeb spObjWeb = site.OpenWeb())
{
SPList spObjDocLib = web.Lists["MyDocLib"];
spObjDocLib.ReadSecurity = 2;
spObjDocLib.WriteSecurity = 2;
spObjDocLib.Update();
}
}
Use ListViewWebPart to display listdata from different than current sharepoint site.
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
namespace TestDashboard
{
[Guid("b732479d-6bcd-4dd9-97de-85f11bsdc5cb")]
public class TestDashboard : System.Web.UI.WebControls.WebParts.WebPart
{
public TestDashboard()
{
}
protected override void CreateChildControls()
{
base.CreateChildControls();
ListViewWebPart wp = new ListViewWebPart();
SPSite objSpSite = null;
using (objSpSite = new SPSite("http://SiteColName/SiteName/"))
{
objSpSite = new SPSite("http://SiteColName/SiteName/", objSpSite.SystemAccount.UserToken);
using (SPWeb spweb = objSpSite.OpenWeb())
{
SPList splist = spweb.Lists["ListName"];
wp.ListName = splist.ID.ToString("B").ToUpper();
wp.ViewGuid = splist.Views["All Items"].ID.ToString("B").ToUpper();
wp.ViewType = ViewType.Html;
wp.WebId = spweb.ID;
wp.SuppressWebPartChrome = true;
wp.GetDesignTimeHtml();
this.Controls.Add(wp);
}
}
}
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
EnsureChildControls();
}
}
}
Wednesday, December 2, 2009
Customize EditForm.aspx, AllItems.aspx or any forms.
2. Open desired site and then list in folder view.
3. Copy EditForm.aspx and paste it
4. Rename the newly copied EditForm.aspx ( MyEditForm.aspx)
5. In new MyEditForm.aspx go to code view.
6. Search for ListFormWebPart. (WebPartPages:ListFormWebPart)
7. Go to the properties of ListFormWebPart (Webpart properties)
8. Check the hidden check box under layouts section. (Layouts/Hidden)
9. THen,
10. Go to Insert menu.
11. Select Sharepoint Controls.
12. Add Custom List Form.
13. It will expose the whole webpart in a form of text boxes,lables and all HTML controls.
You can play with them by hide/show or whatever you want to achieve. Nice enough???
Note: By doing so, you will also able to add column values for Folder also. I mean, generally you can not add properties of Folder, unlike you can do for a list item or a Document. But this process will enable you to add properties of folder.
Monday, November 30, 2009
Accept mail and create an item in Document Library
Go to Document Library Settting -> Incoming mail setting(Under communication tab)
Really good one!!
Help Link :
http://blogs.msdn.com/selvagan/archive/2008/01/26/incoming-email-configuration-moss.aspx
Application page with UnsecuredLayoutsPageBase
See the code sample given below:
public class Class1 :UnsecuredLayoutsPageBase
{
protected Label lblSiteTitle;
protected Label lblSiteID;
protected DropDownList DropDownList1;
protected override void OnLoad(EventArgs e)
{
SPWeb site = this.Web;
lblSiteTitle.Text = site.Title;
lblSiteID.Text = site.ID.ToString().ToUpper();
}
protected void Button_Click(object sender, EventArgs e)
{
Response.Write(DropDownList1.SelectedValue);
}
}
Get List Data using SPView
SPWeb spWebTest = siteCollection.RootWeb.Webs["Test"];
SPList splTestDetails = spWebTest.Lists["TestTeam"];
//Get the Test person names from Test site
SPView spvTestPerson = splTestDetails.Views["TestPerson"];
DataTable dtTestPerson = splTestDetails.GetItems(spvTestPerson).GetDataTable();
SpDisposeChecker tool - check memory leak in sharepoint
http://code.msdn.microsoft.com/SPDisposeCheck
Another good one for .Net : http://msdn.microsoft.com/en-us/library/ee658248.aspx
Thursday, November 19, 2009
Few very useful paths for sharepoint professionals
- 12 hive
- Assembly
- WSS for Web.config changes
- <%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,PublicKeyToken=71E9BCE111E9429C" % >
Friday, November 13, 2009
Flash in Sharepoint
Use following code for source of CEWP
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" id="worldtime" align="middle">
<param name="allowScriptAccess" value="servernamesharepoint" />
<param name="movie" value="http://servernamesharepoint/Test/TestDoclib/flashslide.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="http://servernamesharepoint/Test/TestDoclib/flashslide.swf" quality="high" bgcolor="#ffffff" name="worldtime" align="middle" allowScriptAccess="servernamesharepoint" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
Friday, November 6, 2009
Saturday, October 31, 2009
Windows 2008 Server - Deploy Dll in Gac
2. Open second command prompt. Go to start --> Command Prompt as Administrator --> "
explorer [path to directory where the dll is located]"
3. Drag drop the dll from the source directory to the GAC. Thats done.
Thursday, October 29, 2009
Custom activity with full code for creating folder in list/Library with action file code
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
namespace CreateFolder
{
public partial class Activity1 : Activity
{
public static DependencyProperty FolderNameProperty
= DependencyProperty.Register(
"FolderName", typeof(string), typeof(Activity1));
[DescriptionAttribute("FolderName")]
[CategoryAttribute("FolderName Category")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public string FolderName
{
get
{
return ((string)(base.GetValue(Activity1.FolderNameProperty)));
}
set
{
base.SetValue(Activity1.FolderNameProperty, value);
}
}
public static DependencyProperty BaseUrlProperty
= DependencyProperty.Register("BaseUrl", typeof(string), typeof(Activity1));
[DescriptionAttribute("BaseUrl")]
[CategoryAttribute("BaseUrl Category")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public string BaseUrl
{
get
{
return ((string)(base.GetValue(Activity1.BaseUrlProperty)));
}
set
{
base.SetValue(Activity1.BaseUrlProperty, value);
}
}
public static DependencyProperty ListNameProperty
= DependencyProperty.Register("ListName", typeof(string), typeof(Activity1));
[DescriptionAttribute("ListName")]
[CategoryAttribute("ListName Category")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public string ListName
{
get
{
return ((string)(base.GetValue(Activity1.ListNameProperty)));
}
set
{
base.SetValue(Activity1.ListNameProperty, value);
}
}
public static DependencyProperty InvokeEvent
= DependencyProperty.Register("Invoke", typeof(EventHandler), typeof(Activity1));
[DescriptionAttribute("Invoke")]
[CategoryAttribute("Invoke Category")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public event EventHandler Invoke
{
add
{
base.AddHandler(Activity1.InvokeEvent, value);
}
remove
{
base.RemoveHandler(Activity1.InvokeEvent, value);
}
}
public Activity1()
{
InitializeComponent();
}
protected override ActivityExecutionStatus
Execute(ActivityExecutionContext executionContext)
{
// Raise Invoke Event to execute custom code in the workflow.
this.RaiseEvent(Activity1.InvokeEvent,
this, EventArgs.Empty);
string strIndrajeet = FolderName;
string strBaseUrl = BaseUrl;
string strDocLibName = ListName;
SPSite spsite = new SPSite(strBaseUrl);
spsite = new SPSite(strBaseUrl, spsite.SystemAccount.UserToken);
using (SPWeb spweb = spsite.OpenWeb())
{
spsite.AllowUnsafeUpdates = true;
spweb.AllowUnsafeUpdates = true;
SPFolderCollection folders = spweb.GetFolder(strBaseUrl + "/" + strDocLibName).SubFolders;
bool boolFolderNotCreated = true;
if (!spweb.GetFolder(strBaseUrl + "/" + strDocLibName + "/" + strIndrajeet).Exists)
{
folders.Add(strIndrajeet);
boolFolderNotCreated = false;
spweb.Update();
}
int count = 1;
while (boolFolderNotCreated)
{
string folderName = strIndrajeet + "_" + Convert.ToString(count);
SPFolder spfTemp = spweb.GetFolder(strBaseUrl + "/" + strDocLibName + "/" + folderName);
if (!spfTemp.Exists)
{
folders.Add(folderName);
boolFolderNotCreated = false;
spweb.Update();
}
else
{
count++;
boolFolderNotCreated = true;
}
}
}
// Indicate that the activity has completed.
return ActivityExecutionStatus.Closed;
}
}
}
<strong>.Aciton file entry (under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\1033\Workflow)</strong>
<blockquote></blockquote>""""
<workflowinfo>
<actions parallel="and" sequential="then">
<action category="List Actions" appliesto="all" assembly="CreateFolder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=effbcf4c7d0dab8e" classname="CreateFolder.Activity1" name="Create Folder">
<ruledesigner sentence="Create Folder in List %2 with folder name %1 under site %3">
<fieldbind id="1" designertype="TextArea" field="FolderName">
<fieldbind id="2" designertype="TextArea" field="ListName">
<fieldbind id="3" designertype="TextArea" field="BaseUrl">
</ruledesigner>
<parameters>
<parameter name="FolderName" direction="In" type="System.String, mscorlib">
<parameter name="ListName" direction="In" type="System.String, mscorlib">
<parameter name="BaseUrl" direction="In" type="System.String, mscorlib">
</parameters>
</action>
</actions>
</workflowinfo>
<strong>Web.Config Entry</strong>
<authorizedtype assembly="CreateFolder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=effbcf4c7d0dab8e" authorized="True" typename="*" namespace="">
Wednesday, October 28, 2009
Tuesday, October 27, 2009
Tuesday, October 13, 2009
A very good link for image search in Sharepoint
How to crawl the content in sharepoint search
2. Shared Services Administration: SharedServices1 > Search Administration > Content Sources
3. Local Office SharePoint Server sites
4. Start Full Crawl
Thursday, October 1, 2009
Single Sign On Help
My Site help
Important Paths for Creating custom theme in sharepoint
Theme folders -- C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES
mycustomtheme.gif - C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES
Tuesday, September 29, 2009
Increase the size of Site Template or List Templates
stsadm -o setproperty -propertyname max-template-document-size -propertyvalue 50000000
Monday, September 21, 2009
Sharepoint Installation Help
Thursday, September 17, 2009
Download ifilter for Sharepoint PDF Search
Change default action of the workflow task in Sharepoint
User should be edit the task using only single click. here are the steps to achieve this thing.:
Step1. Open master page. and put following javaScript code in the head part of the master page.
function GoToLink(elm)
{
try
{
if (elm.href==null)
return;
var ch=elm.href.indexOf("?") >=0 ? "&" : "?";
var srcUrl=GetSource();
if (srcUrl !=null && srcUrl !="")
srcUrl=ch+"Source="+srcUrl;
var editUrl, regExp;
var dispUrl = elm.href ;
regExp = /DispForm.aspx/i;
editUrl = dispUrl.replace(regExp, "EditForm.aspx");
var targetUrl= editUrl + srcUrl;
if (isPortalTemplatePage(targetUrl))
window.top.location=STSPageUrlValidation(targetUrl);
else
window.location=STSPageUrlValidation(targetUrl);
}
catch(e)
{
alert(e.description);
}
}
Step 2. Make Defer="false" in following markup code in the master page.
3. THe default action of task has been changed to edit item.
4, isnt it cool user experience??
Monday, September 7, 2009
SharePoint Best Practices Conference Notes (London 2009)
http://www.sharepointology.com/general/sharepoint-best-practices-conference-notes-london-2009-day-1/
Day 2:
http://www.sharepointology.com/general/sharepoint-best-practices-conference-notes-london-2009-day-2/
Wednesday, July 29, 2009
Business Data Catalog Definition Editor
Integrated with SharePoint Server 2007 Software Development Kit (SDK).
After installing SDK you can find it under:
C:\Program Files\2007 Office System Developer Resources\Tools\BDC Definition Editor
Must have for MOSS developers
1. SharePoint Server 2007 SDK: Software Development Kit
http://www.microsoft.com/downloads/details.aspx?FamilyId=6D94E307-67D9-41AC-B2D6-0074D6286FA9&displaylang=en
Monday, July 27, 2009
Create a sharepoint webpart
1. Create a simple webusercontrol . Put necessary code and controls in it.(For ex, datagrid and code to connect database.) Do not maintain separate code file (ascx.cs) for web user control. Put code in same ascx file only.
2. Put the webusercontrol (.ascx file) in layout folder of sharepoint site where you want to deploy the webpart.
3. Go to VS2008. (Please install VSSWSE.exe before that.)
4. Create new Project -> Select webpart from Visual C# -> sharepoint
5. Add following code :
protected override void CreateChildControls()
{
base.CreateChildControls();
// TODO: add custom rendering code here.
Control objControl = Page.LoadControl("/_layouts/WebUserControl.ascx");
this.Controls.Add(objControl);
}
6. Build and deploy the solution.
7. Go to the sharepoint site -> Site Actions -> EditPage ? Add Web Part.
8. Select your webpart from the list.
Saturday, July 25, 2009
Learning Resources for sharepoint
1. http://manish-sharepoint.blogspot.com/2009/04/training-material-on-microsoft-office.html
2. http://sharepointdevtest.blogspot.com/
3. http://qmoss.blogspot.com/
Thursday, July 23, 2009
Check "Sign In Automatically" checkbox in Login.aspx of sharepoint
You will be required to put following java script in the login page.
Wednesday, July 22, 2009
FBA with LDAP in Sharepoint
=================
http://www.codedigest.com/Articles/Sharepoint/94_Active_Directory_for_FBA_in_SharePoint_using_LDAP.aspx
http://msdn.microsoft.com/en-us/library/bb975136.aspx#MOSS2007FBAPart1_BasicSetup
http://msdn.microsoft.com/en-us/library/bb975136.aspx
Thursday, July 16, 2009
Business Data Catalogs on MOSS2007 and SQLServer2008
Monday, July 13, 2009
Sharepoint Installation
Wednesday, July 8, 2009
Monday, July 6, 2009
Tuesday, June 9, 2009
Sharepoint Branding tools for Themes, MasterPages and Stylesheets
Wednesday, June 3, 2009
Sharepoint Webpart using WebUserControl of asp.net
Tuesday, June 2, 2009
Visual Studio 2005 extensions for .NET Framework 3.0 (Windows Workflow Foundation)
Required to develop custom workflows and custom activities
Monday, June 1, 2009
Windows sharepoint services extensions for Visual Studio 2008
It is required to develop custom webpart or any other custom sharepoint stuff.
http://www.mediablend.co.uk/blog/CategoryView,category,SharePoint2007WebParts.aspx
Caching in Sharepoint (Moss2007, WSS3.0)
Tuesday, May 19, 2009
About Inline coding drawbacks in sharepoint2007
Thursday, May 14, 2009
Wednesday, May 13, 2009
About ONET.XML - Good One
Wednesday, April 29, 2009
Lookup fields processing in custom activity
If you are using SharepointWorkflows with some custom activities you might face this problem.
In your custom activities, you might need dynamic content input from user while creating workflows.
Mail text would be the best example for the same.
In custom activity such as mail send with attachments, needs dynamic content.
For example,
Hi [%List:Username%]
.....
......
Thanks,
[%List:Sender%]
This kind of dynamic content will not be parse if you directly use the input parameter without Helper.ProcessStringField.
Without this processing custom activity will treat it as a string. and and in mail you will get Hi [%List:Username%] text. (instead of Hi Indrajeet..)
So to fix of the problem,
before using the input in mailsend function you should procees it by using Helper.ProcessStringField(stringFromUserInput, objActivity, this.__Context))
Ex. String retValue = Helper.ProcessStringField(stringFromUserInput, objActivity, this.__Context))
Virtual paths for layouts and theme folders
For themes :
/_Themes/Folder1/test.css
For Layouts :
/_Layouts/Folder2/Page1.aspx
Wednesday, April 22, 2009
Good link to create round corner images
Wednesday, April 1, 2009
Hide sharepoint Contextmenu(ECB)/ Remove sharepoint Contextmenu(ECB)
Core.Js findings:
- In Core.Js, under path C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033
function AddSharedNamespaceMenuItems creates following context menu items.
View Item,
Edit Item,
Manage Permissions
You can override the functions in MasterPage to modify the context menu.
- To Hide context Menu in sharepoint. Override following function of core.js.
AddListMenuItems -- Hides Context Menu from list.
For more details mail me at indrajitk@gmail.com
Steps to hide Context menu for list items:
1. Just go to core.js file(C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033)
2. find AddListMenuItems function.
3. You will find following code in this function, if (typeof(Custom_AddListMenuItems) !="undefined") { if (Custom_AddListMenuItems(m, ctx)) return; }
4. You can override AddListMenuItems function by Implementing Custom_AddListMenuItems(m, ctx) function in any global place(I did it in master page.). Do not put any code in this function except return false True;
5. No context menu will be displayed for list items.
Monday, January 5, 2009
Catch the exception caused by massive file size upload in asp.net 2.0
Put the code in Global.asax under c:\Inetpub\wwwroot\wss\VirtualDirectories\80
void Application_Error(object sender, EventArgs e) { //To catch the error caused by masssive file size upload more than 4MB. HttpException httpEx = Server.GetLastError() as HttpException; if(httpEx.ErrorCode == -2147467259) { HttpContext.Current.Server.ClearError (); HttpContext.Current.Server.Transfer("ErrorMessage.aspx"); } } |
Friday, January 2, 2009
Few Interesting Things about IIS6
- While uploading, IIS6 never returns any error until it completely absorbs the uploaded file.