Sandip Patil's blog

Sandip Patil's blog on technology

Find all ContentByQueryWebPart from the page programatically

leave a comment

[csharp]
Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager manager = web.GetLimitedWebPartManager("Pages/default.aspx", PersonalizationScope.Shared);
 
foreach (Microsoft.SharePoint.WebPartPages.WebPart webPart in manager.WebParts)
{
 //<type name="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart, Microsoft.SharePoint.Publishing, Version=14.0.0.0,   Culture=neutral,    PublicKeyToken=71e9bce111e9429c">;

       Type type = webPart.GetType();
        if (type.FullName.Contains("ContentByQueryWebPart")
        {
         //then it is ContentByQueryWebPart
        }
}
[/csharp]

Written by Sandip Patil

January 10th, 2012 at 3:56 pm

worldofsharepoint.com now blog.sandippatil.com

leave a comment

Hi Friends,
I have moved my blog worldofsharepoint.com to new domain that is blog.sandippatil.com, all the old articles you can find here.

Written by Sandip Patil

October 1st, 2011 at 5:45 pm

Posted in SharePoint

Unable to open SharePoint site on host machine

leave a comment

Few weeks back, i created one SharePoint site means a web application using Central Admin. One thing which i did different from usual is Host hearder entry. After creating site i tried to open it using host header or say fully qualified name but i couldn’t open it on my local machine but though i can open it from other machines.

Also one more problem i was facing at the time of creating new SharPoint project from Visual Studio 2010. Error like below

Cannot connect to SharePoint Site: http://<sitename>/. Make sure that this valid URL and the SharePoint site is running on the local computer. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL Property of the project.

One of my friend gave me this useful link that i am sharing with you

http://support.microsoft.com/kb/896861

To create/open project in Visual Studio try to use host header URL not machine name or localhost.

Written by Sandip Patil

August 19th, 2011 at 1:02 pm

Sharepoint: User Type field in schema.xml

one comment

I was writting schema.xml for Custom List Template, there i need field of type User like below

[xml]
<Field
ID="{080FF274-4FAB-43c9-9710-78F3A76925DC}"
Type="User"
DisplayName="My User"
StaticName="MyUser"
Name="User"
Required="TRUE"
UserSelectionMode="PeopleOnly"
ShowField="Name" >
</Field>
[/xml]

I was setting value of ShowField property to Job Title which i was using in CAML query to filter out the users. I searched lot for ShowField values of User type but i coudn’t found anything from MSDN, even not an expected results from google. I am very much habitual of seeing the View Source of the HTML pages so i see the page source of Task list’s User column and i got all the values from that source. See image below

So i think looking out HTML pages source is not a bad practice :)

Written by Sandip Patil

May 5th, 2011 at 5:17 pm

Posted in Lists,SharePoint

Webpart Preview Page: Event handler not firing in webpart

3 comments

Today i faced realy strange issue with button event handler in webpart, my webpart created from SharePoint webpart class. This is code

[csharp]

public class MyFirstWebPart : Microsoft.SharePoint.WebPartPages.WebPart
{
Label userName = new Label();
Button button;

protected override void CreateChildControls()
{
button = new Button();
userName.Text = "Sandip";
button.Text = "Change this text";
button.Click+=new EventHandler(button _Click);
this.Controls.Add(userName);
this.Controls.Add(button);
}

protected void button _Click(object sender, EventArgs e)
{
userName.Text = "Sandip Patil";
}
}

[/csharp]

I wired up event handler in CreateChildControls method so that was not an issue. Issue is with testing webpart on the page. I was testing webpart on webpart preview page. You can find webpart preview page whenever you select any webpart from webpart gallery page. After 1 hour of wasting time, i created one webpart page and put that webpart inside webpart zone. Thereafter i could see that event handler was firing. Means problem was not with the code but with testing scenario.

Be careful when you test webpart on Webpart Preview page.

Good Bye, Have a nice time…!

Written by Sandip Patil

April 21st, 2011 at 7:37 pm

Posted in Issues,SharePoint,Webparts

Tagged with

What is new in Visual Studio 2010 for SharePoint Developer?

leave a comment

Many of us are curious about new features of VS 2010 for SharePoint, Microsoft has provided good articles about this on their official site but we couldn’t find this easily because keywords are not well defined for this entries.

First checkout the informational

What’s New in SharePoint Development

then watch below video

Visual Studio 2010 for SharePoint 2010 Development

Enjoy SharePointing…!

Written by Sandip Patil

March 11th, 2011 at 4:50 pm

SharePoint 2010: Choice column not supported in lookup

4 comments

One of the issue or we can say a bug that i found in new SharePoint 2010 version and it is confirmed from Microsoft team.

Issue is like this,

If you try to create a lookup column and select list from which you are setting lookup column, you will not get choice field columns in primary as well as secondary fields. For testing purpose take Task list and check the fields in dropdown as well as checkbox

ID
Title
Modified
Created
Version
Title (linked to item)
% Complete
Start Date
Due Date

You never get Priority and Status columns

On one of the Microsoft blog, i found a post where they say it is supporting but it’s not true, Here below it is

Create list relationships by using lookup and unique columns

get confirmation from this post

Restrictions on additional columns available for addition with Lookup column?

Hope in upcoming hotfix this bug will be solved…!


Written by Sandip Patil

February 26th, 2011 at 5:34 pm

Posted in Issues,SharePoint

Tagged with

Awarded Microsoft Community Contributor

2 comments

Hi Friends,

Today i have been awarded as Microsoft Community Contributor, Thanks Microsoft and all Friends/Microsoft Community Members who trust on me and my contributions.

Written by Sandip Patil

February 17th, 2011 at 4:24 pm

Posted in Awards,SharePoint

Cannot create folder “_layouts\MyCustomPage.aspx”. at Microsoft.SharePoint.Library.SPRequestInternalClass.EnableModuleFromXml(String bstrFeatureDirectory, String bstrUrl, String bstrXML) in Provision of File

leave a comment

Hi friends, i have noticed one strange thing in file provisioning using feature. Let’s see how slash will affect the provisioning.

Case 1 Using forward slash

I write my element manifest (module.xml) like below

[xml]

<?xml version="1.0" encoding="utf-8" ?>
<Elements Id="913FC07E-5953-4813-98F8-241847ED588D" xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="MyCustomPage" Url="_layouts/MyCustomPage">
<File Url="Default.aspx" Type="Ghostable" />
</Module>
</Elements>

[/xml]

When i use Url attribute like Url=”_layouts/MyCustomPage” then feature provision or you can say put my file into site, by creating _layouts folder under root of the site like below (I checked in SPDesigner)

http://sandip:6666

|- _layouts
|- MyCustomPage
|- Default.aspx

Case 2 Using backward slash

I write my element manifest (module.xml) like below

[xml]

<?xml version="1.0" encoding="utf-8" ?>
<Elements Id="913FC07E-5953-4813-98F8-241847ED588D" xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="MyCustomPage" Url="_layouts\MyCustomPage">
<File Url="Default.aspx" Type="Ghostable" />
</Module>
</Elements>

[/xml]

In this case i got one error while feature activation

Cannot create folder “_layouts\MyCustomPage”. at Microsoft.SharePoint.Library.SPRequestInternalClass.EnableModuleFromXml(String bstrFeatureDirectory, String bstrUrl, String bstrXML)
at Microsoft.SharePoint.Library.SPRequest.EnableModuleFromXml(String bstrFeatureDirectory, String bstrUrl, String bstrXML)

In this case in thought feature try to provision or put a Default.aspx file into _layouts directory on 12 hive file directory but that is not case here, i manually create MyCustomPage directory in _layouts. No results, i got same error even i m site collection admin as well as farm admin. I found syntax issue in Url , there should not be special letter like “\”. Please see Module schema here

One conclusion we can make from this

Provisioning is only for the files that needs to go in to the Site directories not 12 hive file directories

Written by Sandip Patil

February 4th, 2011 at 9:32 pm

Posted in Issues,SharePoint

Failed to instantiate file “webpart1.webpart” from module “Web Parts”: The specified list does not exist

leave a comment

Many of us seen this issue while activation of feature on SharePoint site. One common mistake we do is, activating feature in subsite.

Thing is like this, we have http://sandip:6666/ site, which is root site and suppose test is our subsite. we go to http://sandip:6666/test/ and access Site Features from Site Actions and activate the feature. This action will went down into an above error message.

This Error is self descriptive, whenever we activate the webpat feature, feature will try to put .webpart file into webpart gallery. It will utilize url path which is given in element manifest file. In element manifest we defined webpart gallery path to Url=”_catalogs/wp” . This url is nothing but webpart gallery url http://sandip:6666/_catalogs/wp/Forms/AllItems.aspx which is non accessible from subsite.

Always activate feature in root web site, not in subsite.

Written by Sandip Patil

February 3rd, 2011 at 5:35 pm

Posted in Issues,SharePoint