Skip to main content

Posts

Showing posts from June, 2010

Show Current Time via JavaScript

This Code will show client side current time.  You just have create a div with a JavaScript function call as shown below. js_clock(); JavaScript Function: function js_clock() { var clock_time = new Date(); var clock_hours = clock_time.getHours(); var clock_minutes = clock_time.getMinutes(); var clock_seconds = clock_time.getSeconds(); var clock_suffix = "AM"; if (clock_hours > 11) { clock_suffix = "PM"; clock_hours = clock_hours - 12; } if (clock_hours == 0) { clock_hours = 12; } if (clock_hours < 10) { clock_hours = "0" + clock_hours; } if (clock_minutes < 10) { clock_minutes = "0" + clock_minutes; } if (clock_seconds < 10) { clock_seconds = "0" + clock_seconds; } var clock_div = document.getElementById('js_clock'); clock_div.innerHTML = "<strong>" + clock_h...

LOCK in SQL Server

In SQL Server 2000 (Enterprise Manager) 1. Expand server – management-current Activity-expand Locks/processid and you will be able to see all the locks related information. 2. Expand server – management-current Activity-expand Locks/object you can see locks by object information. In SQL Server 2005 (SSMS, object Explorer) Expand-server-management-double click Activity Monitor. On left side you have three options to choose from, select those options and you can see all the locks related information. Run this stored procedure in the database. 1.  sp_lock To know the running process in the sql server, run this query, 2. select * from sysprocesses (in sql server 2000) 3. select * from sys.sysprocesses (in sql server 2005) 4. sp_who 5. sp_who2 will also give you some good information. To work around the locks, you can run profiler to check which query is creating a lock and if that is necessary. Types of locks on object level, (general idea) Database : Database....

Max Length not working for Multi Line Text Box : Solution

In almost all the web projects, we require a multiline TextBox control. It was annoying to find that maxLength property doesn't work on multiline textboxes. There is a workaround to accomplish this using RegularExpressionValidator. Following is the markup that will restrict the text box to maximum of 500 characters. OR You it can be done so easily using javascript functions. I suggest that we should put a javascript validator function so that user will not be able to enter characters more than the length specified, even cant paste any text with more than specified characters. Here are those javascript functions. TextBox Control Javascript: // Keep user from entering more than maxLe...

document.createElement not working on Firefox

document.createElement not working on Firefox Javascript method document.createElement() worked perfectly in all browsers other than FireFox. I changed this part 1: var newElement = document.createElement( "<input name='" +elementName+ "' id='" + elementName + "' type='hidden'>" ); to this: 1: var newElement = document.createElement( "input" ); 2: newElement.setAttribute( 'name' ,elementName); 3: newElement.setAttribute( 'id' ,elementName); 4: newElement.setAttribute( 'type' , 'hidden' ); and now its working with all browsers      

Convert a DataTable to HTML

The Following function will return a HTML formatted string for the given dataset. Some line are commented, you can remove comments if you need. CODE: DataTable dtPriceDetails = SOME DATA TABLE       if  (dt.Rows.Count > 0)   {   string  StringDataTable = ConvertToHtmlFile(dtPriceDetails);   }         public   static   string  ConvertToHtmlFile(DataTable targetTable)     {        string  myHtmlFile =  "" ;      if  (targetTable ==  null )         {            throw   new  System.ArgumentNullException( "targetTable" );   }          else     ...