How to truncate the data in the column
VB.NET Protected function TruncateData( Byval strNotes as string) If strNotes.Length > 20 then Return strNotes.Substring(0,20) + '...' Else return strnotes End function C# protected string TruncateData( string strNotes ) { if (strNotes.Length > 20) { return strNotes.Substring(0,20) + '...'; } else { return strNotes; } }
How the browser name can be detected?
We can use navigator.appName property, to identify the browser we are using .For Netscape browsers, the value of navigator.appName is ‘Netscape’. For Microsoft Internet Explorer browsers,the value of navigator.appName is ‘Microsoft Internet Explorer’ . The following code is used for browser detection. function BrowserDetect() { document.write(’navigator.appName = ’+navigator.appName+’ ’) document.write(’navigator.userAgent = ’+navigator.userAgent+’ ’) if ((navigator.userAgent).indexOf('Opera')!=-1) { document.write('You are using an Opera browser.') } else if (navigator.appName=='Netscape') { document.write('You are using a Netscape browser.') } else if ((navigator.appName).indexOf('Microsoft')!=-1) { document.write('You are using Microsoft Internet Explorer.') } }
I am writing my own HttpHandler. Why is session state not working?
Your HttpHandler has to implement the ‘marker’ interface IRequiresSessionState or IReadOnlySessionState in order to use session state.
How can i form a regular expression which identifies a valid whole number without decimal places?
The regular expression used to identify only the numbers is var regexp = /\D|\./. <script> function IdentifyNumbers() { var Number = document.getElementById('NumericValue').value; var regexp = /\D|\./ ; if(Number.match(regexp)) { alert('Only enter numbers and no decimal point\nInvalid input: '+Number.match(regexp)); } else { alert('Valid Input'); } } </script>
How do I determine the time taken for a long operation that I perform?
You could use the DateTime.Ticks property to record the time taken for a long operation, as follows: [C#] private void MyLongOp() { long startTicks = DateTime.Now.Ticks; // Perform a long op: long endTicks = DateTime.Now.Ticks; long delta = endTicks - startTicks; MessageBox.Show('Time taken in Ticks: ' + delta.ToString()); delta = delta/(long)10000000; // A tick is 100 nanoseconds MessageBox.Show('Time taken in seconds: ' + delta.ToString()); } [VB.Net] Private Sub MyLongOp() Dim startTicks As Long = DateTime.Now.Ticks ’ Perform a long op: Dim endTicks As Long = DateTime.Now.Ticks Dim delta As Long = endTicks - startTicks MessageBox.Show('Time taken in Ticks: ' + delta.ToString()) delta = delta/(Long)10000000 ’ A tick is 100 nanoseconds MessageBox.Show('Time taken in seconds: ' + delta.ToString()) End Sub