Skip to main content

Posts

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))     ...

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" ) {                 ...