Wednesday, December 19, 2012

People Picker to add users to SharePoint 2010 group - Namespace prefix 'xsd' is not defined

Hi All,

We have recently migrated from SharePoint 2007 to SharePoint 2010. Upon trying to add users to SharePoint group, we got the below error:

System.InvalidOperationException: Namespace prefix 'xsd' is not defined.    at System.Xml.Serialization.XmlSerializationReader.ToXmlQualifiedName(String value, Boolean decodeName)     at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderDictionaryEntryArray.Read1_Object(Boolean isNullable, Boolean checkType)     at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderDictionaryEntryArray.Read2_DictionaryEntry(Boolean checkType)     at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderDictionaryEntryArray.Read3_ArrayOfDictionaryEntry()

The problem here is we have a known issue with people picker not working properly in IE9..

Possible Resolutions:

Solution 1 (Temporary Solution)

Change the Document Mode to IE-8 using IE - developer toolbar as shown below








Solution 2 (Permanent Solution)

In System master page, change the content attribute in meta tag from IE-9 to IE-8 as shown below.

<meta http-equiv="X-UA-Compatible" content="IE=8"/>

Hope this helps some one. Thanks !!!

Sunday, December 16, 2012

This item is no longer available. It may have been deleted by another user

Hi All,

We have recently migrated to SharePoint 2010 from MOSS 2007. Everything works great except that for all out of the box libraries like Pages, Document libraries, up on trying to click context menu, we get below error:

"This item is no longer available. It may have been deleted by another user".












Resolution:

1. Edit the pages library/(or documents library) page that is causing this problem and edit the properties of pages web part. Then save the page without modifying anything.

2. Now, i see that context menu is working fine without any issues.
Not sure if this is the right approach but i believe this error is because of List View webpart. Upon saving, this is saving correctly with out any xsl errors. 
Hops this helps some one. You can also follow my msdn post for this error here

Value does not fall with in expected range error with SPListItem

Hi All,

We got the below error while trying to retrieve list item data using SPListItem.

"Value does not fall with in expected range".

This happens only with few columns. We get this error while trying to get data from a lookup column.The list we are trying to get data from has 12 lookup columns. But SharePoint list by default can have only 8 lookup columns to be able to successfully queried. Of course, Farm administrators can query data with out any problem but for normal users, we get the above error.

Resolution:

1. Select the web application and click Resource Throttling













2. We have a setting called "List View Lookup Threshold". This is set to 8by default as shown below. 











3. We changed it to 13 since our list already has 12 lookup columns. After doing so, even normal users are able to query list without any problems.

Hope this helps some one.

The specified file is larger than the maximum supported file size.

Hi All,

We got the below error when trying to upload a file of size 1GB in document library.

"The specified file is larger than the maximum supported file size."
















SharePoint 2010 by default allows file size upto 50MB. However, we can change this setting by few simple steps.

1. Select the web application and click General settings








2. We have a setting called Maximum Upload size. This is set to 50MB by default as shown below. Change it to the size as per your requirement and you are good to go!








Tuesday, November 6, 2012

WebPart Maintenance Page in SharePoint

Hi All,

WebPart Maintenance page is used to close Web Parts on your page, restore defaults to Web Parts, or delete Web Parts from your page.

To go to this page, just type contents=1 in query string.

Example: http://sp2007/default.aspx?contents=1

WebPart Maintenance Page screen:












We can close, delete the webparts by just selecting them using checkbox.

Thank you !

Wednesday, September 5, 2012

Cannot make a cache safe URL for "styles/~/SampleProject/StyleSheet.css", file not found. Please verify that the file exists under the layouts directory.

Hi All,

While trying to register a CSS file in SharePoint using CSSRegistration class as:

// Register CSS File
CssRegistration.Register("~/_layouts/SampleProject/StyleSheet.css");

We got the following error:

"Cannot make a cache safe URL for "styles/~/SampleProject/StyleSheet.css", file not found. Please verify that the file exists under the layouts directory".






One of the benefits of using SharePoint:CSSRegistration is that it prevents multiple loading of same CSS file. For Example, if we try to register a CSS file multiple times as:


// Register CSS File
 CssRegistration.Register("/_layouts/SampleProject/StyleSheet.css");
 CssRegistration.Register("/_layouts/SampleProject/StyleSheet.css");
 CssRegistration.Register("/_layouts/SampleProject/StyleSheet.css");
 CssRegistration.Register("/_layouts/SampleProject/StyleSheet.css");

The final rendered Page will have only one instance of this style sheet.

Ok. Coming back to the problem, the Resolution is to remove ~ in the URL. Hence, the correct statement would be:


// Register CSS File
 CssRegistration.Register("/_layouts/SampleProject/StyleSheet.css");

Here is a good source to know more about SharePoint:CSSRegistration:
http://tommdaly.wordpress.com/2012/05/02/sharepoint-cssregistration-or-link/

Thanks !

Thursday, August 30, 2012

Telerik Tree to Add, Edit, Delete, Move Up and Move Down Nodes

Hi All,

We had a requirement to have a Telerik Tree to perform the below operations on Nodes:

a. Add a Node
b. Edit a Node
c. Delete a Node
d. Move Up a Node
e. Move Down a Node
f. Drag and Drop Nodes with in Tree

We will be having XML in a separate XML file (TelerikTreeXML.xml). Below is the mock up of how it looks:

<?xml version='1.0' encoding='utf-8'?>
<Tree>
  <Node Text='ParentNode1' Expanded='False'></Node>
  <Node Text='ParentNode2' Expanded='False'></Node>
  <Node Text='ParentNode3' Expanded='False'></Node>
  <Node Text='ParentNode4' Expanded='False'></Node>
  <Node Text='ParentNode5' Expanded='False'></Node>
</Tree>

We need to load this XML content from TelerikTreeXML.xml file and bind it to the Tree as shown below:


protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        RadTreeView.LoadContentFile("~/XML/XMLFile.xml");
    }
}

We have a context menu which will be displayed on right click of a node as shown in below image:


















Below is the code to display context menu (Javascript)

function setMenuItemsState(menuItems, treeNode) {
    for (var i = 0; i < menuItems.get_count(); i++) {
        var menuItem = menuItems.getItem(i);
        switch (menuItem.get_value()) {
            case "1":
                formatMenuItem(menuItem, treeNode, 'Add');
                break;
            case "2":
                formatMenuItem(menuItem, treeNode, 'Edit');
                if (treeNode.get_level() == 0) {
                    menuItem.set_enabled(false);
                }
                break;
            case "3":
                formatMenuItem(menuItem, treeNode, 'Delete');
                if (treeNode.get_level() == 0) {
                    menuItem.set_enabled(false);
                }
                break;
            case "4":
                formatMenuItem(menuItem, treeNode, 'Move Up');
                if (treeNode.get_isFirst() == true || treeNode.get_level() == 0) {
                    menuItem.set_enabled(false);
                }

                break;
            case "5":
                formatMenuItem(menuItem, treeNode, 'Move Down');
                if (treeNode.get_isLast() == true || treeNode.get_level() == 0) {
                    menuItem.set_enabled(false);
                }
        }
    }
}


and here is the code for formatMenuItem function:

function formatMenuItem(menuItem, treeNode, formatString) {
    var nodeValue = treeNode.get_value();
    if (nodeValue && nodeValue.indexOf("_Private_") == 0) {
        menuItem.set_enabled(false);
    }
    else {
        menuItem.set_enabled(true);
    }
}

The operations supported for each and every node depends on the type of node selected. For Example, if the node is Parent Node (that is at first level), then only "Add" operation is supported. Add operation will add child nodes to the selected node. Similarly, if there is only one child for a particular node, then "Move Up" and "Move Down" operations will be disabled. The Enabling/Disabling of node will be taken care by formatMenuItem function.

The below is the code for Telerik:RadTreeView









The below is the link for code used to implement this Tree. Note that this is rough piece of code and is not formatted/optimized. Use it at your own risk.

https://skydrive.live.com/redir?resid=D6A20558D41A4EB9!5260

Enjoy and let me know your comments. Have a great day !!!

Sunday, May 27, 2012

The report parameter is read only and cannot be modified

Hi All,

We have a main report which has 5 subreports in it. We are passing the parameter value from main report to sub report. All subreports works fine but when we try to run the main report, we got the following error:
                           
"The report parameter is read only and cannot be modified."


Resolution:

To resolve the above error, just follow the below steps:
a. Open the Sub Report in Design View
b. Click on Report Properties tab under Reports as shown





c. Select the parameter which is throwing the error. In my case, the parameter "language" was causing the
    problem.
d. Under properties for the parameter, select the "Multi-value" option for the parameter as shown below



















e. Once this is done, just run the main report and was able to render the report without any problem in BIDS.
f. Now, upload the reports in Reports Library
g. Click on the report and select "Manage Parameters"

























h.This will display all the parameters available for a particular report as shown below






i. Make sure that the Language parameter is set to Hidden. The problem was that if the parameter is set to internal, we get the exception that the parameter is read-only and cannot be modified.
j. Once this is done, we are able to render the reports in SharePoint without any problem.

Thanks. 

Sunday, May 20, 2012

Limiting the Export Options for SQL Server Reports

Hi All,

We had a requirement to have only few formats (MHTML, PDF and EXCEL) available for exporting the report data. By default, we have many options available for exporting the report data like MHTML, PDF, EXCEL,CSV, XML, TIFF, Word as shown below:












To limit these options, we need to edit the RSReportServer.config file. To find the location of this file, just search for RSReportServer.config in "%ProgramFiles%\Microsoft SQL Server".

Once this file is found, edit the file and search for <Render> tag. This is a XML structure which has various rendering formats as shown below:









Add the attribute Visible="false" for the format to be hidden. That's it !!! Now, we see only limited format options for report as shown below:








Thanks.

No report servers were found on the specified machine - SharePoint 2007

Hi All,

We got the below error in "Grant Database Access" step when trying to configure reporting services in SharePoint 2007 server.

Error:
"No report servers were found on the specified machine"











Background:
SharePoint 2007 and Database are on seperate machines. Hence, to install reporting services, we have first installed Microsoft SQL Server 2008 R2 Developer Edition with Reporting services database configured in SharePoint Integrated Mode.

We also installed Microsoft SQL Server 2005 Reporting Services Add-in for SharePoint on SharePoint 2007 server. Then, when trying to grant database access in Central Administration, we got the above error.

Resolution:
To resolve this error, we have installed latest version of "Microsoft SQL Server 2008 Reporting Services Add-in for Microsoft SharePoint Technologies" from here.

Once this was done, we were able to render the SSRS reports properly.

Cheers !

Friday, May 11, 2012

Mozilla and Chrome Specific CSS

Hi All,

To add Mozilla specific CSS, just include the CSS inside @-moz-document url-prefix() as shown below:

/* Mozilla Specific CSS */
 @-moz-document url-prefix()  {
    #imgHeaderTD
    {
        display:none;
    }
}

The above code hides the element with ID imgHeaderTD in Mozilla only.

To add Chrome specific CSS, just include the CSS inside  @media screen and (-webkit-min-device-pixel-ratio:0):

/* Chrome Specific CSS */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    #imgHeaderTD
    {
    display:none;
    }
}

Thanks.

Sunday, April 22, 2012

Visual Studio 2010 Just In Time Debugger - Cryptographic Exception

Hello,

A couple of weeks ago, Visual Studio 2010 started giving Just-In-Time debugger message as shown below:















It was not a code issue because we got this debugger message just after VS 2010 is started and frequently in middle of coding.

Solution:
The issue was because of Forefront Identity Manager service. It was disabled in my server. Just enable it and set it to start Automatically.


After this was done, we never got the above debugger message. More details on the issue can  be found here.

Thanks.

Saturday, April 21, 2012

The RPC server is unavailable

Hi,

After the ABCPDF's issue with IE9 is resolved, we got another issue while generating PDF using ABCPDF.dll. The below is the error message:

Source:System.Drawing, Message:The RPC server is unavailable, StackTracke:   at System.Drawing.Printing.PrinterSettings.get_InstalledPrinters()     at WebSupergoo.ABCpdf8.Doc.AddHtmlGecko(String html, Boolean paged, Int32 width, String& err)     at WebSupergoo.ABCpdf8.Doc.AddImageHtml(String html, Boolean paged, Int32 width, Boolean disableCache)     at WebSupergoo.ABCpdf8.Doc.AddImageHtml(String html) 

Resolution:

Make sure that the PrintPool service is running on your server. By default, it was disabled in my SharePoint server. I enabled and set it to start automatically and was able to generate PDF from then.



Cheers !

ABCpdf stopped working after IE9 is installed

Hi All,

We use ABCPDF to generate PDF out of a SharePoint data. The version we use is 8.0.0.5. Till now, everything worked fine and suddenly, ABCPDF stopped working with the below error message:

"ABCpdf could not initiate MSHtml engine for this version of Internet Explorer installed."

The only change done to the server was that IE9 is installed. According to the WebSuperGoo support team, ABCPDF versions below 8.1 do not support IE9. The below is the explanation:

Using IE9 on the same system as older ABCpdf versions may cause this error message. The current release - ABCpdf 8.1 - is fully compatible with IE9 and also provides a new Gecko-based HTML engine.

When converting HTML to PDF, ABCpdf uses the MSHTML component installed with Internet Explorer as the first stage of the process. The issue when using older ABCpdf versions is related to a set of problems Microsoft introduced in IE9. We (and other developers) reported these issues to Microsoft in September 2010 but unfortunately they have not been fixed.

Unfortunately with the official release of IE9 Microsoft released new documentation which says the IHTMLElementRender::DrawToDC function that was required has been deprecated. This is especially unfortunate given that there is no replacement for this function.

Given that Microsoft appears to be unwilling to support these interfaces we would strongly recommend that on new deployments you consider a move to the new Gecko-based HTML engine available in ABCpdf 8. It is just one line of code to select the Gecko rendering engine (see the Doc.HtmlOptions.Engine property).

WorkAround:

Change the Rendering Engine from MSHtml to Gecko by using the below code:
Doc theDoc = new Doc();
theDoc.HtmlOptions.Engine = EngineType.Gecko;
After this issue is resolved, we got one more error which says "The RPC server is unavailable"

Sunday, April 1, 2012

Error occurred in deployment step 'Retract Solution': A timeout has occurred while invoking commands in SharePoint host process

Hi All,

We got this error when trying to deploy the SharePoint solution using Visual Studio 2010.

Error occurred in deployment step 'Retract Solution': A timeout has occurred while invoking commands in SharePoint host process











To resolve this error, make sure the following checks are made:

1. Make sure that Application Pool corresponding to the site on which deployment made is up and running.

2. Restart the Visual Studio and reset the IIS if necessary.

We did the above steps and issue got resolved.

Thanks.

Thread Exception while trying to use HttpContext.Current.Response.End()

Hello All,

We frequently got Thread Exception when using HttpContext.Current.Response.End(). The error is shown below:

Source:mscorlib, Message:Thread was being aborted., StackTracke:   at System.Threading.Thread.AbortInternal()     at System.Threading.Thread.Abort(Object stateInfo)     at System.Web.HttpResponse.End()

This is a known issue when we use methods like HttpContext.Current.Response.End(), HttpContext.Current.Response.Redirect() and Server.Transfer() (Refer Microsoft Support)

The workaroud is to use HttpContext.Current.ApplicationInstance.CompleteRequest instead of Response.End()

Cheers !

Saturday, March 24, 2012

Unable to start debugging on the web server. Unable to connect to the web server. Verify that the web server is running and that incoming HTTP requests are not blocked by a firewall.

Hi All,

If you encounter the error saying that "Unable to start debugging on the web server. Unable to connect to the web server. Verify that the web server is running and that incoming HTTP requests are not blocked by a firewall."












Make sure that the IIS website on which you are debugging is up and running.

To do this, go to IIS Manager, select the website on which we are debugging and start the website.

Friday, March 23, 2012

Claims Based Authentication in SharePoint 2010 using SQL Server Provider


Hi All,

Here's is the best resource to consider when you wanted to set up Claims Based Authentication for SharePoint 2010 using SQL Server Provider.

You can easily setup the Forms Based SharePoint site by following the above post by Kirk Evans[MSFT].

Here are some of the issues I faced during the setup.

Issue 1: Users created in ASPNETDB created using aspnet_regsql.exe are not showing up in SharePoint PeoplePicker.

Solution: This is the most common issue most of the users face. When we are adding the users to ASPNETDB by using IIS Manager (IIS Manager -> Central Admin Site -> .Net Users), the default provider is set to our custom provider as shown below. Here FBAMembership is my custom Membership provider.

Just revert the Membership and Role Provider to their default. This is done by clicking the Roles -> Set Default Provider. Similary, click Providers -> Set Default Provider.

Once this is done, i was able to resolve the users present in ASPNETDB in PeoplePicker as shown below.

The users present in ASPNETDB (Shown in ASP.NET WebSite Administration Tool)

Users shown after searching in Address Book:

























Issue 2:The Forms User is unable to login to SharePoint Site though resolved in People Picker
As shown in the above picture, the forms user (fbaadmin) is the site collection administrator for the site but when tried to login to SharePoint using correct credentials, i was unable to login as shown below:















Obviously, this is an issue with Secure Store Token Service (STS) and below is the error message i got in Event Viewer:
An exception occurred when trying to issue security token: The security token username and password could not be validated
For this, i had to reconfigure the Membership and Role providers for STS and IISReset. Thats it. after that I was able to login to the SharePoint site.

Happy Coding...!!!

Thursday, March 1, 2012

Ambiguous match found

Hi,

The "Ambiguous match found" error is the most annoying error I faced ever. This can occur when more than one component in the the aspx/ascx file have same name.
















For example, here's what I have in default.aspx page.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
         <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </form>
</body>
</html>

And Here's my code in default.aspx.cs.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using System.Text;
using System.Data;
using System.Drawing;

namespace WebApplication
{
    public partial class _Default : System.Web.UI.Page
    {
        string label1 = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }
    }
}

In this case, though the code compiles, we get a run time error saying that "Ambiguous match found". This is because we have a label called "Label1" and a string in .cs file with name "label1".

So, next time you get this issue, make sure that all elements in your solution have unique ID's :)

Happy Coding !!!

Custom Context Menu in SharePoint 2010

Hi All,

We know that sharepoint by default provides context menu option for "Title" field. What if we require a content menu for some other column other than "Title"?

In my case, I need to provide a context menu option for a thumb nail image.

The ViewFields section of picture library looks like this.










Here, I need the content menu for the viewfield "FieldRef Name='PreviewOnForm'/>".

To achieve this functionality, just add the below attributes after Name='PreviewOnForm'

"LinkToItem="TRUE" LinkToItemAllowed="Required" ListItemMenu="TRUE"" as shown below below.









This makes sure that we get a context menu when clicked on the 'PreviewOnForm' field as shown below









Cheers !

Thursday, February 16, 2012

DataView RowFilter

Hi All,

Here is the best resource to learn about RowFilter in DataView.

Also have a look at the way to escape special characters to prevent SQL Injection problems.

Cheers !

Sunday, January 22, 2012

Sending HTML Formatted Emails in SharePoint Designer Workflows

Hi All,

Did you ever faced the problem of emails sent using SPD 2010 showing html tags ?

This is the most common error if you are trying to add your own html tags in workflow's send email activity.

The workaround for this problem is:

1. Add Send Email activity in SPD 2010

2. Select the Send Email activity and click on Advanced Properties as shown below












3. Once you click on Advanced Properties, you will get a popup like this:





















4. Here, as you see, you can add parameters like To Address, CC Address, BCC Address etc.

5. Select Body and Click on the button to the left of fx and insert your custom Html there and Publish the workflow

6. Now, the html tags will not be rendered in emails received !

Cheers

Saturday, January 21, 2012

Restore a Site Collection in SharePoint 2010

Hello All,

Here's is the best resource to restore a deleted site collection in SharePoint 2010 using Powershell.

Cheers!

Monday, January 2, 2012

Download a File from FBA enabled SharePoint Site Programatically using WebClient

Hello All,

We recently had a requirement to download an image from a Forms Based SharePoint site programatically but we always got 403 error (Forbidden) when trying to download using WebClient.DownloadData method.

Fortunately, after some googling, we found this great post which helped me in resolving the problem.

On a high level, this approach uses the SharePoint's Authentication.asmx web service to hit the site using the credentials.

Hope this helps. Have a great year ahead....!