Showing posts with label SharePoint 2010. Show all posts
Showing posts with label SharePoint 2010. Show all posts

Tuesday, June 11, 2013

Difference between System.Web.UI.WebControls.WebParts.WebPart and Microsoft.SharePoint.WebPartPages.WebPart?

Microsoft.SharePoint.WebPartPages.WebPart is provided in MOSS 2007 to provide backwards compatability with MOSS 2003 webparts.

 In MOSS 2007, it is recommended to use System.Web.UI.WebControls.WebParts.WebPart instead.

System.Web.UI.WebControls.WebParts.WebPart does not provides a feature to get or provide to to other webparts.

Client Object Model vs Server Object Model in SharePoint 2010

Client Object Model 

Client object model is a new feature available in SharePoint 2010. .Client object model provides a  way to do the programming for a SharePoint site using scripting language such as Java Script .


In  Client object model an xml request will be sent  and then server will return JSON which is changed to appropriate object model. 

Mainly 2 assemblies to be referred while working with the Client object model.

Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll

Below is the code sample for a list object from SharePoint site using Client object model :
ClientContext context = new ClientContext("http://sp2010:2012");
 List list = context.Web.Lists.GetByTitle("Title");
context.Load(list);
context.ExecuteQuery();
So, what else a developer can do with Client object model. Client object model provide a way where you can access SharePoint data with scripting language such as Java Script.
You can write simple java script code to perform all those operation. You can use CAML query to access data from SharePoint site.


Using Client object model you can do below tasks:
Get list items, Add list items, Update list items and many more.

Client object model gives result in fast manner, but there is a limitation. The limitation is, we can not access Farm Object using Client object model.
For Client object model silverlight is also an option to program for a SharePoint site.

So if you want to access Farm object then use Server object model.


Server Object Model :



Server object model contains following classes : SPFarm, SPServer, SPSite, SPSiteCollection etc.

Below is the code Sample for Server Object Model:
This code is to get the list items from a SharePoint site:

          using (SPSite oSite = new SPSite(@"http://sp2010:33051"))
            {
                using (SPWeb oWeb = oSite.RootWeb)
                {
                    SPList oList = oWeb.Lists["List1"];  
                    Console.WriteLine("Items in: " + oList);
                    foreach (SPListItem oItem in oList.Items)
                    {
                        string firstname = oItem["Fname"].ToString();
                        Console.WriteLine(firstname);
                    }
                 }
            }

If you want more on Client object model or Server object model then please comment your query. Your comment will be highly appreciated.

Wednesday, October 24, 2012

Sharepoint 2013 The context has expired and can no longer be used


I came across this odd error a couple of times in the past few weeks, so I wrote a quick guide that might help you get rid of it.
If you see this error after opening your SharePoint 2013 site, there is a lack of synchronization between Date and Time settings in your SharePoint 2013 Server and your SharePoint web application.
Sorry, something went wrong. The context has expired and can no longer be used. (Exception from HRESULT: 0×80090317)

Here is how you fix it!




  • Open Central Administration -> Application Management.
  • Locate the relevant Web Application and click on 
  • Web Application General Setting window will open up, notice that the Default Time Zone is missing.

Open Date and Time options on your server and check which time zone is configured. Configure the same time zone in Web Application General Setting.


Perform IIS Reset and open your SharePoint 2013 site again.


Hooray! SharePoint site works again!

Ref Link : http://blog.cloudshare.com/2012/10/22/how-to-fix-sharepoint-2013-web-application-error-the-context-has-expired-and-can-no-longer-be-used/#more-3508

Enable Anonymous Access to a SharePoint 2013 site


As is the case in previous versions, you can configure SharePoint 2013 sites to be accessed by anonymous users. In this article I will show the steps needed to configure anonymous access to an existing SharePoint 2013 site.
1. Navigate to the SharePoint 2013 Central Administration in your SharePoint 2013 environment. Under Application Management section, click the “Manage web applications” link.

2. Select one of the available web applications and press the “Authentication providers” button available in the Ribbon. A modal dialog showing the authentication providers available per zone is displayed. As you can see, in a basic scenario only the “Default” zone is listed.


3. Click the “Default” link so a new modal dialog is displayed. Just check the “Enable anonymous access” option and press the “Save” button


4. Navigate to one of the site collections you have created under the configured web application and go to “Configure -> Site Settings”. Under the “Users and permissions” section, click the “People and groups” link.


5. As you can see, SharePoint 2013’s Ribbon display is an “Anonymous Access” button that allows you to configure how anonymous users can access to the site.


6. Press the “Anonymous Access” button in the Ribbon so the related configuration modal dialog is shown. In this dialog you have three configuration options, just click the first one that provides full anonymous access to the site. Press the “OK” button.


7. Back to the “People and Groups” page, check there is a new group called “Anonymous users” available in the list.


8. We are almost done. To finish, start a new instance of a web browser and check that you don’t need to provide credentials information since anonymous access is enabled on the entire site.


And that’s all about how to enable anonymous access to a SharePoint 2013 site. I recommend you check out how it works in your SharePoint 2013 CloudShare environment.

Ref : link:-  https://support.cloudshare.com/entries/22231202-how-to-enable-anonymous-access-to-a-sharepoint-2013-site




Wednesday, September 19, 2012

What is Group Discussion and its Importance - HR Interview Questions

It is a methodology used by an organization to gauge whether the candidate has certain personality traits and/or skills that it desires in its members. In this methodology, the group of candidates is given a topic or a situation, given a few minutes to think about the same, and then asked to discuss the it among themselves for 15-20 minutes.

As in a football game, where you play like a team, passing the ball to each team member and aim for a common goal, GD is also based on team work, incorporating views of different team members to reach a common goal.

Here are some of the most important personality traits that a candidate should possess to do well at a GD:

The skills that are usually assessed in a Group Discussion are:


    * Communication Skills
    * Interpersonal Skills
    * Leadership Skills
    * Motivational Skills
    * Team Building Skills
    * Tolerance to Ambiguity
    * Divergent Thinking
    * Listening skills
    * Presentation Skills
    * Analytical / Logical skills

So, it's important to assess your current strengths in all these areas and accordingly put efforts to strenthen your weaknesses.

What GD Panel Looks for - HR Interview Questions

All that one observes in a GD can be categorized into two broad areas: the Content and the Process. The content is all about the matter (or the 'what') spoken in the GD. Whereas, the process refers to the 'how', 'when' and 'why' of the GD. Both are equally important and need adequate attention at all stages. A high quality contribution with no regard to the 'process' is as suicidal as one which is high on packaging with little content.

Skills of an Individual that are Judged in Group Discussion are:

    * How good you are at communication with others.
    * How you behave and interact with group.
    * How open minded are you.
    * Your listening skill.
    * How you put forward your views.
    * Your leadership and decision making skills.
    * Your analysis skill and subject knowledge.
    * Problem solving and critical thinking skill.
    * Your attitude and confidence.

Important Points to Remember about Group Discussion (GD) - HR Interview Questions

   * It is important for all the members of a group discussion to use reasoning.
    * It is also important for you to ask questions that will allow you to determine how much the other members know about a specific topic.
    * You should not make a statement which gives your opinion about the accuracy of a comment that has been made by another member.
    * If you are the one who is planning or leading the group, it is important to make sure every members contributes something to the discussion.
    * It is important to make sure everyone is talking about the topic. The students should talk and make statements regarding the topic.
    * The best way to approach the topic of discussion is to start with a concept that is simple before moving to one that is complex.
    * Once you have researched the topic, you should develop your own thoughts or opinions about it.
    * To successfully participate in group discussion, you must know how to work well with others, and you must understand the topic or materials that are being discussed.

How to prepare and succeed in an job interview - HR Interview Questions

It has been effectively proven that in majority of all interviews that are done usually has a decision unto the applicants in a matter of minutes. And the rest is just for formality. This will mean that a glossy first impression will be of utmost importance during an interview to ensure that you get the perfect job.

By the time that you are given the knowledge that an interview is on its way. The first move is to observe and study the company that is offering the interview. A good knowledge and understanding with regards to the products and services offered along with who buys these things will be a great advantage at your part. A brief history about the company of your choice will give you something that other applicants would want. And make sure to get good information about the person who will give the interview to you. Mainly his position in the company along with his name.


On your way inside the place, make sure that every single person deserves a smile from you. Cheerfully great them along the way and politely talk with them. Do this as you can never know who among all of the people inside the building has great connections with the interviewer. Go into the establishment ahead of the interview time to make yourself comfortable with the atmosphere in the place and also to gather more information.

Take a good time going through your application and have enough time to think through the things about you so you don’t get blanked during the interview. Another good point is to bring along with you certain certificates that can be proof with regards to your professional and educational history. Do not bluntly show it to the interviewer. Instead, politely wait until this person asks to see it

As you have the time because you have went to the establishment early. Use some of it by thinking about 2 broad questions. This will come in handy because usually in the end of the interview. They tend to ask you if you got a few questions. This will most likely give the interviewer the idea that you are sharp and you think very fast.

Try to make yourself as simple as possible during the interview. Be the honest person that you can only think of before. Be sure to not let them see or at lost do not cross your arms in front of them and do not fold your legs while they see you. Look at them straightly and keep in mind that this whole interview is done only to acquire information’s and observations from you. This means your answers must be flawless along with your movements.

Tuesday, September 18, 2012

Error cannot access a closed file – FileUpload in ASP.NET


This was very interesting error, i got during development of file upload control in ASP.NET.
On my local system, every thing was just fine. but when i deployed my application on development server, my control was able to upload only small size files.
whenever i tried to upload large size file i got error “cannot access a closed file”
After going through MSDN i found that there is one new element added in ASP.NET 2.0 known as httpRuntime.
So i just added this new Tag in my web.config and every thing was right.


<system.web>
<httpRuntime  maxRequestLength="15360" requestLengthDiskThreshold="15360"/>
</system.web>

Note :

requestLengthDiskThreshold should not exceed the maxRequestLengthattribute.

To read more about this, please visit http://msdn.microsoft.com/en-us/library/e1f13641(VS.80).aspx

Friday, July 6, 2012

SharePoint 2010 Foundation server architecture


SharePoint 2010 Foundation server architecture

Microsoft SharePoint Foundation is a free version of of sharepoint 2010 offers a highly structured server-side object model that makes it easy to access objects that represent the various aspects of a SharePoint Web site.
The following diagram shows the SharePoint 2010 Foundation server architecture in relation to the collections and objects of the Microsoft.SharePoint.Administration namespace.
Click on image to zoom


Here is the explation of each point of the SharePoint 2010 Foundation server architecture from top to down:-

1. SPFarm : SPFarm object is the highest object within the SharePoint 2010 Foundation object model hierarchy. it is designed to interact with the configuration data store. It contains global settings for all the servers, services, and solutions that are installed in a server farm. and the Services property gets a collection representing all the services.

Sharepoint SPFarm Example: the following example shows : services and status in sharepoint server farm

SPFarm myFarm = SPFarm.Local;
SPServiceCollection myServiceCollection = myFarm.Services;
foreach (SPService myService in myServiceCollection)
{
Label1.Text += myService.Name + " " + myService.Status + "";
}

2. SPServer : SPServer object represents a physical server computer in the server form. The Service Instances property provides access to the set of individual service instances that run on the individual computer. Use either the Servers property of the SPFarm class, or the SPServerCollection constructor, to get the collection of servers that are used in the specified server farm.

Sharepoint SPServer Example : The following example modifies the name and role of an existing server in the server farm.

SPServerCollection servers = SPFarm.Local.Servers;
SPServer myServer = servers["myExistingServer"];
myServer.Name = "NewServerName";
myServer.Role = SPServerRole.Application;
myServer.Update();

3. SPService : SPService object represents a logical service installed in the server farm. Derived types of the SPService class include, for example, objects for Windows services, such as the timer service, search, the database service, etc. and also objects for Web services, such as the basic content publishing Web service which supports the Web applications.

Sharepoint SPService Example : The following example iterates through the timer jobs history for each service in the farm and reruns any timer jobs that have failed in the past hour.

DateTime oneHourAgo = DateTime.UtcNow.AddHours(-1);
List<Guid> rerunJobIds = new List<Guid>();
foreach (SPService service in SPFarm.Local.Services)
{
foreach (SPJobHistory entry in service.JobHistoryEntries)
{
// stop if the entry didn't occur in the last hour
if (entry.EndTime < oneHourAgo)
break;
if (entry.Status == SPRunningJobStatus.Failed &&
!rerunJobIds.Contains(entry.JobDefinitionId))
{
SPJobDefinition job = SPFarm.Local.GetObject(
entry.JobDefinitionId) as SPJobDefinition;
if (job != null)
{
job.RunNow();
// don't rerun the same job twice.
rerunJobIds.Add(entry.JobDefinitionId);
}
}
}
}

4. SPWebService : SPWebService represents a Web service that contains one or more Web applications. The WebApplications property gets the collection of Web applications that run the service. and the Web service allows a Web browser to access the content in SharePoint sites.

Sharepoint SPWebService Example : The following example iterates through all of the Web services in a server farm and changes the maximum site count and warning site count of all the content databases that are used for each Web application.

SPWebServiceCollection webServices = new SPWebServiceCollection(SPFarm.Local);
foreach (SPWebService webService in webServices)
{
foreach (SPWebApplication webApp in webService.WebApplications)
{
if (!webApp.IsAdministrationWebApplication)
{
SPContentDatabaseCollection contentDatabases = webApp.ContentDatabases;
foreach (SPContentDatabase database in contentDatabases)
{
database.WarningSiteCount = 4900;
database.MaximumSiteCount = 5000;
database.Update();
}
}
}
}

5. Service Application Framework : Service Application Framework provides developers the ability to build scalable middle-tier shared services. Service Application Framework applications is also very helpful while load balancing and a common management and deployment experience in SharePoint 2010. 
this can be tied to a single farm or can be shared across farms.

Sharepoint Service Application Framework Example : An example of a service built on this framework is SharePoint Server search. SharePoint Server search runs on multiple application servers in a SharePoint farm.



Thursday, July 5, 2012

Sharepoint 2010 14 hive directory structure


In Sharepoint 2010 microsoft has replaced the "12 hive" directory structure that we had in SharePoint 2007/Moss2007 with "14 Hive" directory structure in sharepoint 2010.

Some of the new folders came for 14 hive in sharepoint 2010


Click on image to zoom


Sharepoint 2010 14 hive path

the path of 14 hive folder is: C\Program Files\Common files\Microsoft Shared\Web Server Extensions\14

This directory is the installation directory for core SharePoint 2010 Server files, and all the major task are handled by this directory.

Here i would like to explain in detail 14 hive directory structure, none of the underlying folders really have changed but a few things have been added.

Sharepoint 2010 14 hive ADMISAPI


The path for sharepoint point 2010 14 hive ADMISAPI folder is : - Program Files\Common files\Microsoft Shared\Web Server Extensions\14\ADMISAPI


Use of the 14 hive ADMISAPI directory : - Sharepoint 2010 14 hive ADMISAPI directory contains the soap services for Sharepoint 2010 Central Administration. If 14 hive ADMISAPI directory is altered, then the remote site creation and other methods exposed in the service will not function correctly.

Sharepoint 2010 14 hive CONFIG

The path for sharepoint point 2010 14 hive CONFIG directory is : - Program Files\Common files\Microsoft Shared\Web Server Extensions\14\CONFIG

Use of the 14 hive CONFIG directory : - Sharepoint 2010 14 hive CONFIG directory contains files used to extend IIS Web sites with SharePoint Server. If this directory or its contents are altered, Sharepoint web application provisioning will not function correctly.

Sharepoint 2010 14 hive LOGS

The path for sharepoint point 2010 14 hive LOGS directory is : - Program Files\Common files\Microsoft Shared\Web Server Extensions\14\LOGS -

Use of the 14 hive LOGS directory : - Sharepoint 2010 14 hive LOGS directory contains setup and run-time tracing logs.



Sharepoint 2010 14 hive newly added folder

Sharepoint 2010 14 hive Policy

Path for sharepoint point 2010 14 hive Policy directory is : - Program Files\Common files\Microsoft Shared\Web Server Extensions\Policy -

Sharepoint 2010 14 hive UserCode

Path for sharepoint point 2010 14 hive UserCode directory is : -Program Files\Common files\Microsoft Shared\Web Server Extensions\UserCode -



Use of the 14 hive UserCode directory : - Sharepoint 2010 14 hive UserCode directory contains files used to support your sandboxed solutions.


Sharepoint 2010 14 hive WebClients

Path for sharepoint point 2010 14 hive WebClients directory is : - Program Files\Common files\Microsoft Shared\Web Server Extensions\WebClients -



Use of the 14 hive WebClients directory : - Sharepoint 2010 14 hive WebClients directory contains files related to the new Client Object Model.


Sharepoint 2010 14 hive WebServices

Path for sharepoint point 2010 14 hive WebServices directory is : - Program Files\Common files\Microsoft Shared\Web Server Extensions\WebServices -



Use of the 14 hive WebServices directory : - Sharepoint 2010 14 hive WebServices directory contains new wcf or .svc related files.




Note : You should rewrite and recompile any code that refers to files and resources in "12" Hive structure.For example, if you have redeployed all of your files into the "14" folder and emptied your "12" folder, any references to files under the "12" folder will not work.


Monday, April 9, 2012

Step by step create custom list definitions in sharepoint 2010 - List Content Type

Step by step create custom list definitions in sharepoint 2010 - List Content Type

In Sharepoint 2010 Some time we need to create custom list definition - list content type.

It is very easy to create custom list definition with content types in sharepoint 2010 


Today i am writing all step to create custom list definition with content type ..


Open Visual Studio 2010


New Project


Take Empty Sharepoint Project


Click on image to zoom



Here i am creating as a sandbox solution

Give the Site Url

Click on image to zoom


Go To Solution Explorer Add New Item

Select List Definition

Give the name of list definition Here i am giving name Employee List



Click on image to zoom



Give the list definition type and name


Click on image to zoom



From solution explorer under the list instance open Element.xml file


Click on image to zoom



Modify Element.xml

Give relevant Title, description

Give Templatetype="100" for custom list

Give feature ID for custom list type 100 = 00BFEA71-DE22-43B2-A848-C05709900100

feature ID you can find from here

after all modification your xml look like this

Click on image to zoom



Now Select Element.xml from solution explorer under the Employee List

Click on image to zoom


Modify XML File Add field (Give new Guid - create Guid From Guid Generator)

Add Content Type (Give new Guid - create Guid From Guid Generator remove hyphens and add 0x0100 this is depend upon the list type)

Give FieldRef (use same filed guid)

after all modification your xml look like this


Click on image to zoom


 Now Select Schema.xml from solution explorer

Click on image to zoom


Give Content Type Ref (take content type id from Element.xml)

after modification your code look like this

Click on image to zoom


Under the fields add the fields name


Click on image to zoom

Under the view fields modify like this

Click on image to zoom


On header EnableContentTypes="True"

Click on image to zoom


Now Build and deploy your solution ..

Go to Site Action > View All Site Content

You can find your list Employee List


Click on image to zoom


If your List Content type is not configured you can configure like this

Go List Setting > Advanced Settings

Click on image to zoom

Select Allow Management Content Type Yes 

Click on image to zoom

Now Go again list setting 

Under the content types select Add from existing site content types 

Click on image to zoom

 Add your content type from left box 

Click on image to zoom

Now Go again list setting 

Under the content types select select default content type 


Click on image to zoom


Select your content type like below



Click on image to zoom
Now Go to list Add New Item


Click on image to zoom




You can use this content type .. 

Go to Site Action > Site Settings > Site Content types > under the Custom Content Types


Click on image to zoom





Hope this article will help you .. please feel free to contact if you have any query regarding this




Thankyou :)