Sunday 29 August 2010

SharePoint 2010: Cannot find link to Master Page / Page Layouts?

1. Click on “Site Actions”

- Click on “Site Collection Features”

- Enable “SharePoint Server Publishing Infrastructure”

 

2.  - Click on “Site Actions”

- Click on “Manage site features”

- Enable “SharePoint Server Publishing”

Saturday 28 August 2010

Session state can only be used when enableSessionState is set to true ... SharePoint 2010

In web.config

1. <pages enablesessionstate="true">

2. <modules runallmanagedmodulesforallrequests="true">
..
..
<remove name="Session">
<add name="Session" type="System.Web.SessionState.SessionStateModule" precondition="">

3. <pageparserpaths>
<pageparserpath virtualpath="/*" compilationmode="Always" allowserversidescript="true" includesubfolders="true"></pageparserpaths>

Save and exit.

Friday 20 August 2010

How do i get Root Web Url ?

SPContext.Current.Site.RootWeb.Url

Thursday 19 August 2010

LLBLGen - EntityCollection to DataTable Conversion?

public DataTable CollectionToDataTable(EntityCollectionBase collection, string TableName)
where TEntity : EntityBase, IEntity
{
List propertyProjectors =
EntityFields.ConvertToProjectors(collection.EntityFactoryToUse.CreateFields());
DataTable dt = new DataTable(TableName);
collection.DefaultView.CreateProjection(propertyProjectors, dt);
return dt;
}

Reference: http://www.llblgen.com/tinyforum/GotoMessage.aspx?MessageID=77377&ThreadID=3861

Thursday 12 August 2010

Get Display Name from Account Name

SPContext.Current.Web.EnsureUser["domain\account"].Name;

Tuesday 10 August 2010

CheckBoxList Checked Items

public static class CheckBoxListExtender 
{
public static List<ListItem> CheckedItems(this CheckBoxList list)
{
List<ListItem> col = new List<ListItem>();
foreach (ListItem item in list.Items)
{
if (item.Selected)
col.Add(item);
}
return col;
}
}

“An unexpected error has occurred” error message in SharePoint.

Here are the steps for getting the full error messages

1)Go to the MOSS site for which you would like to enable it.

Most likely to be found at c:\inetpub\wwwroot\wss\VirtualDirectories and a sub directory with your web application’s port number.

2) Locate and open the web.config file for editing.

3)Find out the following entry

<SafeMode MaxControls=“200“ CallStack=“false“ DirectFileDependencies=“10“ TotalFileDependencies=“50“ AllowPageLevelTrace=“false“>

And make following changes to it

<SafeMode MaxControls=“200“ CallStack=“true“ DirectFileDependencies=“10“ TotalFileDependencies=“50“ AllowPageLevelTrace=“true“>

4) And

<customErrors mode=“On“ />

To

<customErrors mode= “Off“ />

5)Save and close web.config.


Reference:
http://nishantrana.wordpress.com/2009/03/24/%E2%80%9Can-unexpected-error-has-occurred%E2%80%9D-error-message-in-sharepoint/

SharePoint Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.

in web.config

<trust level="WSS_Minimal" originUrl="" />
to
<trust level="Full" originUrl="" />

Visual Studio Tip: Get Public Key Token for a Strong Named Assembly

cmd:
sn -T Name.dll

http://blogs.msdn.com/b/miah/archive/2008/02/19/visual-studio-tip-get-public-key-token-for-a-stong-named-assembly.aspx

Saturday 7 August 2010

How to remove Site Actions and View All Site Content

<SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl2" runat="server" PermissionsString="ManageWeb">


<<SharePoint:SiteActions control>>

 
</SharePoint:SPSecurityTrimmedControl>

To check the permission set Enumeration check this:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx

Reference: http://www.sharepointkings.com/2008/11/how-to-remove-site-actions-and-view-all.html