Skip to main content

Posts

Publish/Upload the documents to document library from local hard drive

I am sharing function to upload your files on local hard drive to SharePoint document library. In my scenario I have a file on local hard drive and upload this to a SharePoint document library and delete the file presented on local drive. The source code is // For Publish file to library private void PublishWorkbook(string strTempLocalPath, string strLibraryURL, string strFileName)         {             SPSecurity.RunWithElevatedPrivileges(delegate()                    {                        using (SPSite siteCollection = new SPSite(SiteURL))                        {   ...

Get excel column name by a known integer number

I am sharing with you a small function that enables you to get excel column name by a known integer number. function private string GetExcelColumnName(int columnNumber) { int dividend = columnNumber; string columnName = String.Empty; int modulo; while (dividend > 0) { modulo = (dividend - 1) % 26; columnName = Convert.ToChar(65 + modulo).ToString() + columnName; dividend = (int)((dividend - modulo) / 26); } return columnName; } Way to call methods string strRange = GetExcelColumnName(5); output strRange = E

Best Practices for Speeding Up Your Web Site

This article is a copy of a Yahoo Developer article , the Exceptional Performance team has identified a number of best practices for making web pages fast. The list includes 35 best practices divided into 7 categories. Filter by category: Content Server Cookie CSS JavaScript Images Mobile All Minimize HTTP Requests tag: content 80% of the end-user response time is spent on the front-end. Most of this time is tied up in downloading all the components in the page: images, stylesheets, scripts, Flash, etc. Reducing the number of components in turn reduces the number of HTTP requests required to render the page. This is the key to faster pages. One way to reduce the number of components in the page is to simplify the page's design. But is there a way to build pages with richer content while also achieving fast response times? Here are some techniques for reducing the number of HTTP requests, while still supporting rich page designs. Combined files are a way to redu...

Get attachment with attachment icon

Recently I have a implemented a functionality in a SharePoint project, Get the attachment from a SharePoint list with a icon according to the type of attachement. After long practice we are able to resolve the same. Now I am sharing you the solution with you, I think it would help to you. Javascript Methods var SiteURL = ''; function getAttachments(ID,ListName) { var PageURL = window.location.href; var LastIndexOfPage = PageURL.substring(PageURL.lastIndexOf("/")); PageURL += "/"; SplitLastIndexOfPage = LastIndexOfPage.split("/"); var FirstIndexOfPage = PageURL.split("/"+SplitLastIndexOfPage[1]+"/"); //var lists = new SPAPI_Lists('http://sharepointdev:123/sites/myteamsite/phases/'); SiteURL = FirstIndexOfPage[0]; var lists = new SPAPI_Lists(SiteURL); var items = lists.getAttachmentCollection(ListName,ID); if (items.status == 200) { var rows = items.responseXML.getElementsByTagName('Attachment'); v...

Resolve 'SPAPI_Lists' is undefined

Problem: 'SPAPI_Lists' is undefined Cause: You forget to attach reference of SPAPI_Core.js and SPAPI_Lists.js. Resolution: Services JS API Includes Required Lists.asmx SPAPI_Core.js SPAPI_Lists.js Copy the SPAPI_Core.js and SPAPI_Lists.js to your application inside folder and include reference of SPAPI_Core.js and SPAPI_Lists.js to your page inside head tag. e.g

SharePoint Tip / Thought of the Day WebPart

I have posted a new web part on codeplex a brief description is provided below URL: http://tod.codeplex.com/ The "Thought / Tip of the Day" Web Part selects a random item from the specified SharePoint Custom List or a selected RSS Feed and displays a picture, a title and a thought/tip. The Web Part can be used with WSS 3.0, MOSS 2007 and SharePoint 2010. You can configure the following web part properties: • the SharePoint list containing the thoughts / tips • RSS Feed URL for external thoughts / tips • the List fields corresponding to the picture, title and thoughts / tips • a picture (Optional) • show a new thoughts / tips every day or on every page refresh This allows you to display random data contained in any SharePoint List by specifying the desired SharePoint List name and the desired list column names. Installation Instructions: 1. download the Thought / Tip of the Day Web Part wsp file 2. Install the wsp file and deploy to server farm. 3. If y...

Importing documents from SQL Server to Document Library

Recently I had come across a requirement where we had to migrate a existing SQL server tables data to a document library. The SQL table was containing documents (blob field and its meta data) i wanted to share with you all the small script we had used for the same string connstr = @”Data Source=.;Initial Catalog=AdventureWorks;Persist Security Info=True;User ID=sa;Password=sa”; SqlConnection conn = new SqlConnection(connstr); conn.Open(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand(“SELECT * FROM [dbo].[ImageStore]“, conn); DataSet ds= new DataSet(); da.Fill(ds); byte [] blob = ( byte [])ds.Tables[0].Rows[0][ "imageContent" ]; using (SPSite destinationSite = new SPSite( "http://YourSite" )) { using (SPWeb = destinationSite.OpenWeb( "http://YourSite" )) { SPList destinationDocuments = destinationWeb.Lists[ "Documents" ]; string fileName = "mydoc.jpg" ; string relativeDestinationUrl = des...