Saturday, August 20, 2011

Customize ReportViewerWebPart in C# for all SharePoint Zones

This is one of the major milestone I have achieved recently to customize the report viewer web part for SharePoint sites. The issue I was facing: the SharePoint site which I have developed was too complex and it exposed via 3 zones. http://intranetsite, http://extranetsite, https://internetsite
  1. http://intranetsite – which is Windows based authentication site and for intranet people.
  2. http://extranetsite – Which is Windows based authentication site and for extranet people
  3. http://internetsite – Which is Forms based authentication site and for internet people.

For each sub site in our implementation it should show the SSRS dashboard report of the site we are in which will contains all information of the site through reports. But, SSRS reporting services and report viewer web part has a limitation in SharePoint integration mode:

System.Web.Services.Protocols.SoapException: The specified path refers to a SharePoint zone that is not supported. The default zone path must be used. ---> Microsoft.ReportingServices.Diagnostics.Utilities.SecurityZoneNotSupportedException: The specified path refers to a SharePoint zone that is not supported. The default zone path must be used.

e-Filing of Income Tax Returns online INDIA

Yes, using the e-filing process one can file in tax returns just within a few clicks at any time of the day and that too without any hassles. Using this technology all you have to do is fill the form and submit it, online or offline.

This is one of the best option available to us. It is very difficult to file for the income tax returns in regular process. Where as the e-filing process is simple and there is no need to dependent on anyone and you can do yourself with the required documents and information. The very first time you will face simple issue but it will be the nicer process once you get in. So, start using this feature and enjoy.

How to file Income Tax Returns

Process of E-filing of tax returns

The above links are quite enough to do what you are looking for. So, please use them to not miss to get your income tax returns.

Sunday, August 7, 2011

Set Page Layout programatically for a publishing page

If you like to create pages in site through code then you have to set the page layout for the page. Below is the simple code which does that works well.
private static void SetPageLyoutToPublishibPage()
        {
            using (SPSite site = new SPSite("http://SP2010Site"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
                    PageLayout pageLayout = null;
                    foreach (PageLayout p in publishingWeb.GetAvailablePageLayouts())
                        if (p.Name.Equals("BlankWebPartPage.aspx", StringComparison.InvariantCultureIgnoreCase))
                        {
                            pageLayout = p;
                            break;
                        }

                    PublishingPage page = publishingWeb.GetPublishingPage(web.ServerRelativeUrl + "/Pages/Default.aspx");
                    page.CheckOut();
                    page.Layout = pageLayout;
                    page.Update();
                    page.CheckIn("");
                }
            }
        }
Any issues, please post it here.

Set default Page Layout for a SharePoint site

Before reading this post, please take a look at this post: Get default Page Layout for a SharePoint site.
Setting default page layout to a SharePoint site is very important. For example if you are trying to create a new site/web template in SharePoint and from it you like to create sites then do not forget to set default page layout [especially in SharePoint 2010].
private static void SetDefaultPageLayout()
        {
            using (SPSite site = new SPSite("http://SP2010Site"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);                    
                    PageLayout pageLayout = null;
                    foreach (PageLayout p in publishingWeb.GetAvailablePageLayouts())
                        if (p.Name.Equals("BlankWebPartPage.aspx", StringComparison.InvariantCultureIgnoreCase))
                        {
                            pageLayout = p;
                            break;
                        }
                    publishingWeb.SetDefaultPageLayout(pageLayout, true);
                    publishingWeb.Update();
                }
            }
        }
Here, I have set the Blank Web Part page as the default page layout to the SharePoint site. This way you can control the logic as your wish...

Get default Page Layout for a SharePoint site

Sometimes when you are provisioning sites through web/site templates you might miss one thing that setting default page layout for the web. In SharePoint 2010 especially you have to face this issue when you try to browse to the page "Page layouts and Site Templates" from site settings page. If there is no default page layout then there are problems while creating new page as well. So, this could be a major issue in some special cases.

Sometimes you might get the error like "Data at the root level is invalid. Line 1, position 1" because of this.
So, we have to know is there any default page layout set for the site and below is the perfect console application solution for it.
        private static void GetDefaultPageLayout()
        {
            using (SPSite site = new SPSite("http://SP2010Site/"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);

                    PageLayout pageLayout = publishingWeb.DefaultPageLayout;
                    Console.WriteLine(pageLayout.Name + "Url : " + pageLayout.ServerRelativeUrl);
                }
            }
        }
So, this way you can trace easily some kind of problems which create problems to us. :)

Copy users from one SharePoint group to another group

This is one of the question raises from many people who has to copy users from one SharePoint group to another group. There is no direct way you can directly copy users through browser. So, it could be problem to site owners and administrators to add all users again. How to solve these kind problems?

Here are some scenarios of why it is actually needed?
  1. There are so many SharePoint groups in the site and need to copy the users from one group to another group.
  2. Two sites needed same permissions and one site group permissions need to copy to another group.
So, from the ways I know below are the possibilities.