Skip to main content

Posts

Showing posts from 2012

Flot Graph is not rendering on IE9

You might have come across a situation when you use jquery.flot.js for graphs ,flot graphs were not generated in IE9 due to the following Javascript Error in "jquery.flot.js" file. While debugging you will get the error like : "unable to get value of the property "init_" : object is null or undefined ". In  the method ConstuctCanvas(), in place of this snippet: ------------------------------------------------------------------------------ function makeCanvas(width, height)       {         var c = document.createElement('canvas');         c.width = width;         c.height = height;         if ($.browser.msie) // excanvas hack           c = window.G_vmlCanvasManager.initElement(c);         return c;       } ------------------------------------------------------------------------------  Use the following snippet ------------------------------------------------------------------------------------- function makeCanvas(width, height)

Environment set up for Microsoft SharePoint Foundation 2010 with search server express

In the SharePoint world, Many a times after installing everything including search server express, when you tried to crawl the contents, it may give some nonsense error  and you may not be able to understand what it is. The solution i have come across is , during the installations of required software you have to take care . The search server  express might not be having certain files which is required for search to work properly.  For that you need to install service pack .     Here are the procedure to set up the environment for SharePoint : Download Microsoft SharePoint Foundation from the below link:             http://www.microsoft.com/en-us/download/details.aspx?id=5970      2. Download Search Server express from the below link:            http://www.microsoft.com/en-us/download/details.aspx?id=18914      3. Download the SP1 for Microsoft SharePoint foundation:            http://www.microsoft.com/en-us/download/details.aspx?id=26640 After installing MS SQL ful

SharePoint farm backup using PowerShell script

Being SharePoint administrator, taking the backup of farm is the basic need in SharePoint administration. Using the Powershell script we can take the backup of entire SharePoint Farm.  Following is the powershell script to take the backup of entire sharepoint farm           Backup -SPFarm -Directory D:SharePointSIteBackUp -BackupMethod full In the above script,  D:SharePointSIteBackUp is the backup location on hard disk. Here i have create a folder called SharePointSiteBackup inside the D drive. Most important thing is, Do not provide any space or special characters between the words while giving name to the backup folder. Because while running the script, it gives an error. So folder name should be without space.  This may help someone Cheers -Pradeepa Achar

SharePoint site upgrade utility using C#

Hi people,     Recently in my spare time i have developed an windows form application which does SharePoint site up gradation without using either stsadm command or powershell script..  My windows form application looks as follows The functional over view: On click on Load button (1) present at the top , it should load all the Solutions present in the solution repository in the SharePoint central administration and add all the solution names to the dropdown present below the load button(1). private void loadSolBtn_Click( object sender, EventArgs e)               {                      foreach ( SPSolution sol in SPFarm .Local.Solutions)                      {                            if (!cmbDeploy.Items.Contains(sol.Name))                            {                                   cmbRetract.Items.Add(sol.Name);                            }                      }               } Note:In the above code, the

How to get the SharePoint central admin url programmaticaly via C#?

I had come across a situation where i had to get the sharepoint central admin's url.. You can follow the following snippet of the code. At the begining add the namespace  using Microsoft.SharePoint.Administration; SPAdministrationWebApplication centralAdminFarmUrl =  Microsoft.SharePoint.Administration.SPAdministrationWebApplication.Local ; String  centralAdminUrl = centralAdminFarmUrl.Sites[0].Url;  This may help someone -Cheers Pradeepa Achar

“An exception of type Microsoft.SharePoint.Upgrade.SPUpgradeException was thrown. Additional exception information: Failed to call GetTypes on assembly Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c. Could not load file or assembly 'System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.”

While running the product configuration wizard of Sharepoint foundation 2010, if you have come across the following error “ An exception of type Microsoft.SharePoint.Upgrade.SPUpgradeException was thrown. Additional exception information: Failed to call GetTypes on assembly Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c. Could not load file or assembly 'System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.” Here is the solution to overcome the issue,. Open the SQL server configuration manager.Select the SQL Server Network Configuration and select the Protocols for MSSQLSERVER. Make sure that TCP/IP protocol is enabled. If it is disabled, make it enable by right clicking on the TCP/IP ,Click on Enable option. Hope

The timer job for this operation has been created………..”

While deploying/retracting the solution using stsadm command , you may come across this error message The solution for the above problem as follows: § Go to central admin->monitoring->Review job definitions under Timer jobs §   Search for .wsp on the page .You will find a timer job “ XYZ.wsp is deploying / retracting ……blab la. ” §   Click on the XYZ.wsp is retracting/deploying timer job and click on the “DELETE” button. §   Now goto Services . goto start->Run->enter the text services.msc .find the service name “ Sharepoint 2010 Administration ” and start the service. §   Now continue with the process of deployment or retraction using stsadm command. This may help some one Cheers Pradeepa Achar

error occurred in deployment step 'recycle iis application pool' :object reference not set to an instance of an object

While deploying using Visual studio, we may get an error "error occurred in deployment step 'recycle iis application pool' :object reference not set to an instance of an object" Solution:  Don't get  panic ..Simply restart the visual studio with the solution which you wanted to deploy on to the site This may help some one. -cheers pradeepa achar

Programmatically read the value from web.config file

Here is a situation where you need to keep a key value pair element in the web.config file and read them during the run time. I suggest, better keep key /value pair under <appSettings> element and read it programmatically . <appSettings>   <add key=" LicenseKey " value=" 987jKouterhsk " /> </appSettings> Assume , you have added a license key as above in the web.config file. You need the license key during run time. You can access the license key class named "ConfigurationManager". write a property  called getLicenseKey and return the corresponding license key. public string GetLicenseKey {    get{   return  ConfigurationManager.AppSettings[" LicenseKey "]; } } Now the property GetLicenseKey will have the value 987jKouterhsk. Use this value as per your requirement. -Cheers Pradeepa Achar

How to get youtube video id ,prepare the IFrame and play the video using jQuery

<body>     <form id="form1" runat="server">     <div>     <input id=" vdo " />     </div> <div> <button id=" btn" >Click</button> </div> <div id=" fnl "> </div> <script> $(document).ready(function () { $(" #btn ").click(function (e) { e.preventDefault(); var url = $(" #vdo ").val(); var youtubeUrl = url.match(/watch\?v=([a-zA-Z0-9\-_]+)/); var source ="http://www.youtube.com/embed/" + youtubeUrl[1] ; output = '<iframe width="420" height="420" src="'+ source +'"  frameborder="0" allowfullscreen></iframe>'; $(" #fnl ").html(output); }); }); </script>     </form> </body> Hope this will help Cheers Pradeepa Achar

How to avoid refreshing of page on clicking on BUTTON in jQuery?

Suppose you might have created a button on page.When you click on that button without page refresh some other custom things have to happen. But instead of that, on clicking on the button the page is getting refreshed. How to avoid this?.. Simple, The button click event has default event as refreshing the page. The solution is to "prevent the default event". $("#ButtonID").Click(function(e) {   e.preventDefault(); //Write your custom code here } ); Hope this may help Cheers Pradeepa Achar

How to get the Server's name programmatically and make it as local host url in C#?

It is very simple.You can get the Server name as follows public string serverName = System.Windows.Forms.SystemInformation.ComputerName.ToLower(); Inorder make the serverUrl, you can follow as public string serverUrl = "http://" + System.Windows.Forms.SystemInformation.ComputerName.ToLower(); Hope this will help Cheers Pradeepa Achar

How to iterate through all items from a folder which is present in 14 hive layouts folder and add them as drop down options?

Suppose you have a Combo box( it is for drop down in asp.net) object  called "ddmItems". First get the path to the file present in the 14 hive layouts folder as below string   targetPath =  SPUtility .GetGenericSetupPath( @"TEMPLATE\LAYOUTS\FOLDER_NAME\TARGET_FOLDER_NAME" ); Now iterate in  the TARGET_FOLDER present in the 14 hive layouts folder and  add to the combo box object(ie. “ddmItems”). foreach   ( var   directoryItem   in   Directory .GetDirectories(targetPath)) {          DirectoryInfo   info =   new   DirectoryInfo (directoryItem);          string   fileName = info.Name;       //Check whether the file name is already added to the drop down          if   (!ddmItems.Items.Contains(fileName))        {          ddmItems.Items.Add(fileName);        } } Hope this will help cheers Pradeepa Achar

How to upload document to each item of the Sharepoint list?

Suppose you have a variable which is holding path to the file including the filename along with the extension. string srcUrl = Target_Path_To_The_Directory + "\\FILE_NAME.doc" ; Using the following code you can upload file to the item of the SharePoint list SPList list=SPContext.Current.Web.Lists[“LIST_NAME”]; SPListItem item=list.Items.Add(); FileStream fStream = File.OpenRead(srcUrl); string fileName = fStream.Name.Substring(3); byte[] contents = new byte[fStream.Length]; fStream.Read(contents, 0, (int)fStream.Length); fStream.Close(); item.Attachments.Add(filename, contents); item.Update(); Hope this will help Cheers Pradeepa

How to get the path to the 14 hive layouts folder programmatic ally using C# ??

Hi All,     I had come across a situation where i had to access to one of the folder in 14 hive layouts folder. I accomplished in this way. string pathToTargetFolder = SPUtility.GetGenericSetupPath (@"TEMPLATE\LAYOUTS\FOLDER\TARGET_FOLDER"); The variable "pathToTargetFolder" now holds the path to the folder "TARGET_FOLDER" in layouts folder. Hope this will help. Pradeepa Achar

How to limit the character entry into a text box in jQuery?

Hi All,         I had come across a situation where i need to limit the character count into a text box. Suppose, your there is a requirement where the text box should take only 20 characters. In this situation preferably use the keypress method for even to happen as follows $( '#IdOfTheTextBox’ ).keypress( function (e) {               if (e.which < 0x20) { //This snippet you have to use , otherwise it will not allow you perform action using  backspace or delete button on FireFox                      return ;               }               if ( this .value.length == "20" ) {                      e.preventDefault();               }               }); By doing above, it will not allow you to enter characters after 20the character. Hope this will help . cheers Pradeepa Achar

What is "/g" in Regular expression?

Being a techno geek i was searching an answer , what is the use of "/g" in regular expression.Usually while writing regular expression we add /g at the end of the regular expression . for example, there is a regular expression     /[^a-zA-Z0-9 ]/ g .The answer is simple:  The g on the end after the  / means do a global replace - if you leave it off then only the first match will be replaced. Cheers Pradeepa achar

Add data to GridView and Export GridView data to Excel sheet

Suppose , you have data stored in a array of structure. let us say,    public struct myData    {       string name;       int age;       string city;      public myData(string pName,int pAge,string pCity)         {           name=pName;           age=pAge;           city=pCity;         }     } ............... public void dataTableData() {        List<myData> items=new List<myData>();        ...add name,age,city of each person to the object 'data'.    //Now you need to add data present in the object 'items' to the GridView DataTable table=new DataTable(); DataRow row=null; //Create three columns 'Name','Age','City' table.Columns.Add(new DataColumn("Name",typeOf(string)); table.Columns.Add(new DataColumn("Age",typeOf(int)); table.Columns.Add(new DataColumn("City",typeOf(string)); //Now loop through the items present in the object 'items' foreach(myData item in

I have began to Explore REST Services...

Now i am very much keen to know about REST services.!!!!! What is this REST services? Whilre retreiving data from server, most of the time our mind goes to Webservice. There is some thing beyod the webservice, by using which we can retrieve data in strongest way.That is through "REST". I have got an video link on  Youtube , by following the instruction you can explore ,how to use REST services... I am going to post certain thing about REST services shortly..:)..

The Fastest way to Export Schema of Sharepoint List

Many of my SharePoint Developer friends are struggling to get the Schema.xml file of a newly created list. The schema.xml file has the list's metadata information, by using the schema.xml, we can create the lis definition and paste this contents of Schema.xml to the Schema.xml file of the newly created List definition, so that you can deploy the list definition on another site. In order to do this, you guys might be following the procedure bu saving the site template and get the site definition solution. After this, you will open visual studio and import this solution and wait for few minutes. THIS IS A CRAPPY PROCEDURE..Why do you invest your time to get a schema of one or few list  by taking entire site definition?..If that site has lots of lists, then it will take lots of time. In my Research, i have found a the BEST  and quicker way to get schema.xml file of a particular list which you need Schema.xml. Follow the following procedure : Go to your site  click on the lis

Setting Up the Development Environment for SharePoint 2010 on Windows Vista, Windows 7, and Windows Server 2008

 Usually we can install microsoft Shapoint foundation on servers OS such as windows server 2008 .You might have tried to instal sharepoint foundation software on your client OS such as Vista,Windows7,etc.Here i have got a msdn link .You can follow the steps they have mentioned and you can successfully install the SharePoint Foundation on your client OS.    Follow this Post Cheers Pradeepa

How to find the internal name of a column in Sharepoint

Some of you guys have question about where we can get the internal name of a column of a sharepoint's list. Many guys have posted like, we can get by using CAML query builder and some other blaa blaa stuff.. Actually you can get easily . 1.Click on the list in which the column exists. 2.click on the list setting and  click on the column name . 3.In the browser, in the url section go to the end of the url. You will find Field = internalName.

stsadm

For a sharepoint developer/Admin stsadm command is a must known command. I am going to explain how to use the stsadm command. 1.In order to retract solution from  your site, you can use the command like as follows. stsadm -o retractsolution -name "solutionName.wsp" -url "site url from which you want to retract the solution" -immediate 2. In order to add solution to the solution repository present in the central administration stsadm -o addsolution -filename "path to the solution present in your local hard disk/solutionName.wsp" 3.In order to deploy the solution on particular site stsadm -o deploysolution -name "solutionName.wsp" -url "site url" -immediate -allowgacdeployment -force There are few more use of stsadm command .You can explore if you want Thanks