How to open .pdf file in the browser from sharepoint

Bydefault pdf files are not open in the browser from sharepoint. when we click on pdf file it will download to client machine.

But if we want to open pdf file in the browser we need to do changes for that site in central administration.

Changes as follows.

1. Open central administration–> Applicatioin Management –> Web Application –>Manage web applications.

2. Now select your web site, Click on General setting in ribbon.

3. Scroll down the modal popup dialog box to “Browser File Handling” . There are two choices one is “Permisive and Strict”. By default “Strict” is selected now change that to “Permissive”. Now scroll down and click ok.

4. Now go to the website (which is select in step2) and upload one pdf file to document library when you click on that document it will open with in the browser.

 

So nice it is…. Thanks

Error Type: “SharePoint Search can’t crawl SharePoint site – Error HRESULT E_FAIL has been returned from a call to a COM component”

When i was working with search site I got the following error which is found in crawl history log.

“SharePoint Search can’t crawl SharePoint site – Error HRESULT E_FAIL has been returned from a call to a COM component”.

What i have done is, first created a search site under the root site and created new crawl content for the root site in central administration. After doing all these things i tried to run full crawl then full crawl completed with one error and obviously wont work.

I just opened crawl history and i saw the error, for the first time i didnt get what it is. i searched a lot for the solution. Finally i got the solution.

Here is the solution.

1.Go to your virtual directory in inetpub folder and open the root site folder and u can find web.config file.

2. Open ur web.config file in note and fine the following line of code ”

  <identity impersonate="false" />"

Now change impersonate=”false” to impersonate=”true” , now perform an iisreset and reran the full crawl.  Success!! .

Now searching working fine….

Reference link is here.

How to display quick launch on newly created webpart page from browser

When you create a webpart page on SharePoint 2010, the quick launch won’t display.

With SharePoint 2010 all you needed to do is:

1.open your webpart page in code view mode in desginer.
2. click on Advanced Mode from the ribbon.

3. find the following two tag and remove.

< asp:Content ContentPlaceHolderId=”PlaceHolderNavSpacer” runat=”server”></asp:Content>
< asp:Content ContentPlaceHolderId=”PlaceHolderLeftNavBar” runat=”server”></asp:Content>

4. And fine the following code and delete

<SharePoint:UIVersionedContent ID=”WebPartPageHideQLStyles” UIVersion=”4″ runat=”server”>
<ContentTemplate>
<style type=”text/css”>
body #s4-leftpanel {
display:none;
}
.s4-ca {
margin-left:0px;
}
</style>
</ContentTemplate>
</SharePoint:UIVersionedContent>

5.Now Save your page.

The quick launch will now display on the web part page.

How to add , deploy and activate a .wsp solution file in sharepoint 2010

First we need to build .wsp file.

How to build WSP file.

open visualstudio 2010 –> File –> New –> Project

select sharepoint 2010 template on leftside panel, .Net Framework 3.5 and select visual web part, click on “OK”.

It will open sharepoint customization wizard, in that specify webapplication url where will u deploy this .wsp file. then click on “finish”.

Now design usercontrol. am taking one button and one label here.

Now press F5.

Here u might get deployment error after build.

Error Msg is: “Error occurred in deployment step ‘Recycle IIS Application Pool’: Cannot connect to the SharePoint site: http://websitename . Make sure that this is a 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.”

ignore that error message. wsp is generated successfully u can find .wsp file in solution bin folder.

Now how to deploy and activate feature.

am copying this file and placing in another location that is “D:\DeploymentFiles”.

we can deploy .wsp using stsadm and powershell.

here am using powershell cmdlets.

1. add solution to sharepoint

Add-SPSolution “D:\Deploymentfiles\Sample4WSP.wsp”

2. Deploy solution to a webapplication

Install-SPSolution –Identity Sample4WSP.wsp –WebApplication http://192.168.0.11:2244 –GACDeployment

3. Activate feature( without activating the feature we cannot see this webpart in webpart gallery).

Enable-SPFeature –Identity Sample4WSP_Feature1 –url http://demoshare:8086

to confirm whether the feature is activated or not we have to execute another command that will show all activated features

“get-spfeature -site http://demoshare:8086 | sort displayname”

How highlight list rows based on Column value

Open your page in SharePoint designer and click on Advanced Mode.

add this code after “</style>” tag.

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js&#8221; type=”text/javascript”></script>
<script type=”text/javascript”>

$(document).ready(function(){
$Text = $(“td .ms-vb2:contains(‘Not Started’)”);
//$Text.css(“background-color”, “#461B7E”);
$Text.css(“color”,”red”);
var myelement = $Text.parent().parent();
$Text = $(“td .ms-vb2:contains(‘Completed’)”);
//$Text.css(“background-color”, “#4CC417”);
$Text.css(“color”,”Green”);
$Text = $(“td .ms-vb2:contains(‘In Progress’)”);
//$Text.css(“background-color”, “#EAC117”);
$Text.css(“color”,”Orange”);

});
</script>

Error Type: Could not load type IDataServiceUpdateProvider when using REST service in sharepoint 2010

I wanted to use the new REST services in SharePoint 2010. But when I navigated to the ListData.svc service. I got the following error: see here

Could not load type
‘System.Data.Services.Providers.IDataServiceUpdateProvider’ from assembly ‘System.Data.Services, Version=3.5.0.9, Culture=neutral, PublicKeyToken=b771a5c561934e089’.

To solve this error we need to install the ADO.NET Data Services update for .NET 3.5 SP1.

download it and install the problem will be resolved.

Download the ADO.NET Data Services Update for .NET Framework 3.5 SP1 for Windows 7 and Windows Server 2008 R2.

Download the ADO.NET Data Services Update for .NET Framework 3.5 SP1 for Windows 2000, Windows Server 2003, Windows XP, Windows Vista and Windows Server 2008.

after installing am able to get the result. see here

How to bind sharepoint list to dropdownlist using API code

if(!IsPostBack)

{

DataSet ds = new DataSet();

SPList list = SPContext.Current.Site.Lists[“ListName”];
DataTable DTable_List = list.Items.GetDataTable();
DTable_List.TableName = “Table1”;
ds.Tables.Add(DTable_List);

DropDownList.DataSource = ds.Tables[“Table1”];
DropDownList.DataTextField = “FieldName”; // list Column Name
DropDownList.DataValueField = “FieldName”; // List Column Name
DropDownList.DataBind();
DropDownList.SelectedIndex = 0;

}

(OR)

SPList list = SPContext.Current.Site.Lists[“Departments”];

DDL.DataSource = list.Items;

DDL.DataValueField = “Title”; // List field holding value

DDL.DataTextField = “Title”; // List field holding name to be displayed on page

DDL.DataBind();

DDL.SelectedIndex = 0;

 

How simple it is!!!!

How to Create External Content Type Using SQL Server Database

Step 1: Open your sharepoint website in sharepoint desinger 2010 and click on External Content Types in left hand side “site objects”. See here

Step 2: Now Click on “External Content Type” on Ribbon. See here

Step 3: Click on “Click here to discover external data sources and define operations” (showned in picture). See here

Step 4: Click on Add Connection button. It will pop up “External Data Source Type selection”.See here

Step 5: Select SQL Server as Data source type.Click on OK. It will pop up “SQL Server Connection”.See here (1) ,(2) ,(3)

Step 6: Now Enter your SQL Server Name, Database Name, and display name.
select “Connect with Impersonated Custom Identity” and enter Secure Store Application ID(remember this Application ID should be
unique, will tell explain how important it is.basically it store sql server username and password). Now click on OK. See 1, 2

Step 7: After click on OK button it will ask “SQL Server username and Password”.Enter SQL Server Credentials and Click on “OK”. See 1, 2

Step 8: now External content type is created. But we didnt created any operation for content type.
See here

step 9: Expand Database which in Data Source Explorer.
Step 10: Select your table which use used to fetch data and display in sharepoint list.See here

Step 11: Right click on table and select “Create All Operations”. See here

Step 12: Click on “NEXT”. See here

Step 13: now set of all column fields will shown here. we can select all or only few. But one column sholud be unique identifier.
Click on “NEXT”. See here

Step 14: Here we can filter table. Otherwise simply click on “Finish”. See here

Step 15: Now we can see all operation in “External Content Type Operations”. See here

Step 16: Now we can create external list.Click on “Create Lists & Form” which located on ribbon.will pop up one box. See here

Step 17: Give external list name in popup box.Click on “OK”. See 1, 2, 3.

Step 18: Now we can see newly create external list in “External Lists” panel. See here

Step 19: Now open your site in browser. See here
Step 20: Select your external list in leftside navigation.It will show error message like “Access denied by Bussiness Data
Connectivity”. See here

While creating external content type we given credential which are not saved anywhere those are only used for to display database in
“Data source Explorer”.

Did get my point leave it follow my steps.

Step 21: Now Go To your central administrator and select “manage service applications” which is “Application Management” section. See here

Step 22: Click on Bussiness Data Connectivity. See here

Step 23: Now you can find your external content type and select your content type. See here

Step 24: Now Click on “Set Object Permissions”,it will open “Set Object Permissions” pop up.

See 1, 2.

Step 25: Enter Account name how can use this content type and Click on Add. Select Permissions Check boxes. Then Click on “OK”.See here
Step 26: Now to go user website and click on ur external list. Here You will Get error message again,but this time error message is different which is “Unable to display this webpart. To troubleshoot the problem, open this web page in a microsoft sharepoint Foundation-coompatible HTML editor such as Microsoft Sharepoint Designer”. See here

Step 27: GO to your central administration site and Select “Application Management” which is in Quick Launch.See here

Step 28: click on “Manage Service applications” which is in “Service applications” section.See here

Step 29: Now select “Secure Store Service”. See here

If you are using this first time it will show one message like “Before creating a new secure store target application, you must first generate a new key for this Secure store service application from the ribbon”. See here

Step 30: Click on Generate new key from the ribbon. See here.

step 31: Give any name which should be strong name. Click on “OK”. See 1, 2

Step 32: Click on “New” on the ribbon. See here

Step 33: SPecify a unique Target application id, display name,contact email(any but should be valid) and Click on “NEXT”.(Remember that This name should be already given while creating External Content Type in Step 6). See 1, 2

Step 34: Click on “NEXT”. See 1, 2

Step 35: Enter Target Application Administrators and Click on “OK”. See here

Step 36: Now you can see newly create Target Application ID. See here

Step 37: now select newly create Target Application ID and click “set” on the ribbon. See here

Step 38: Enter Credentials owner(full control user like administrator), SQL server Database username and password. Click on “OK”. See here

Step 39: Now go to your website and click on external list from quick launch.This time u will get list without any error. See here

Step 40: this step is not require but if you get any error in previous step. GO to your central administrator–>Application Management–>Service application–>select your External content type and Click “Configure” on the ribbon. See here

BCS so beautiful… we can operate all operation on the list and we can find the changes on server.

NOTE: all these screenshot are placed in one location. Each screenshot is a step.

Give your valuable feedback to make this blog more valuable. Thank you.

How to disable Edit form’s fields in sharepoint 2010 using JQUERY based on loggedin user’s group

//Load JQuery file
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js&#8221; type=”text/javascript”></script>

//Load SPService JQuery file which is available at http://spservices.codeplex.com/releases/view/64390
<script type=”text/javascript” src=”/style library/SPServices/jquery.SPServices-0.6.2.js”></script>

<script type=”text/javascript”>
$(document).ready(function () {
$().SPServices({
operation: “GetGroupCollectionFromUser”,
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function (xData, Status) {
if ($(xData.responseXML).find(“Group[Name=’UK_Sample’]”).length == 1) { //Replace the “UK_Sample” with your group name will tell that user is on a particular group or not.
$(“input[Title=’Title’]”).attr(“disabled”, “disabled”); //Disabling Title Text field, for text field we use input
$(“input[Title=’Due Date’]”).attr(“disabled”, “disabled”);
$(“input[Title=’Start Date’]”).attr(“disabled”, “disabled”);
$(“div[id$=’_UserField_upLevelDiv’]”).attr(“contentEditable”,false); //Disabling People picker
$(“span[id$=’_UserField’]”).find(“img”).hide(); //hiding search field and check which are adjacent to people picker
$(“Select[Title=’Priority’]”).attr(“disabled”, “disabled”); //Disabling DropDown, for dropdown we use SELECT
//$(“input[Title=’Description’],textarea”).attr(“disabled”, “disabled”);
}
}
});
});

// while saving we need to enable filed, for this we simply remove disable attribute. Other wise we will get error
function PreSaveAction() {
$(“input[Title=’Title’]”).removeAttr(“disabled”);
$(“Select[Title=’Priority’]”).removeAttr(“disabled”);

return true;
}
</script>

Thats it. JQuery is superb…