Friday 30 September 2011

Javascript date objects

javascript date and time object

The Date object is useful when you want to display a date or use a timestamp in some sort of calculation. In Java, you can either make a Date object by supplying the date of your choice, or you can let JavaScript create a Date object based on your visitor's system clock. It is usually best to let JavaScript simply use the system clock.

Get Hour, Second and Minute from Current time (VB.net)

<script language="vb" runat="server">

    Sub Page_Load()

Get Hour from DateTime

Imports System

Public Class Greeting
     Shared Sub Main()
        Dim dtCurrent As System.DateTime
        Dim iHour As Integer

        dtCurrent = dtCurrent.Now()
        iHour = dtCurrent.Hour

        If (iHour < 12Then
            Console.Writeline("Good Morning!")
        End If
        If (iHour >= 12And (iHour < 18Then
            Console.WriteLine("Good Afternoon!")
        End If
        If (iHour >= 18Then
            Console.WriteLine("Good Evening!")
        End If
    End Sub

End Class

Mid Function


The Mid function returns a specified number of characters from a string. The Mid function returns the portion of the designated string for a designated length starting from any position in the string. The Function will return the requested number of characters from a string. The Length of Characters To Pull parameter is optional. 

Javascript code to get first day of a month

<html>
<head>
<script type="text/javascript">

JavaScript Date functions


Date Object

The Date object is used to work with dates and times.
Date objects are created with new Date().
There are four ways of instantiating a date:

Friday 23 September 2011

OOPs Interview Questions

Q: How will you define a CLASS ?

A: All classes in Visual Basic. NET are defined in a .VB file (as oppose to .CLS file in vb6), Also .VB file may contain one or more classes. The basic syntax of a class is as follows:

What is Boxing and UnBoxing?

Description: 
Before We talk about Boxing and Unboxing let us understand aboutC# types.  
Value Types:
A variable representing an object of value type contains the object itself. (It does not contain a pointer to the object). Different value types are

In which namespace does StringBuilder class exist?

n which namespace does StringBuilder class exist?
Answer:
 System.Text namespace.

Thursday 22 September 2011

C# - Singleton Pattern vs. Static Classes

Problem: Store some common data in a singleton or static class about your program in an object array, which you store in a class. It saves state between usages and stores some caches, and must be initialized only once and shared in many code locations. Making a new object each time would be expensive.

Solution

Wednesday 21 September 2011

Download to Excel from dataset


da = New SqlDataAdapter(cmd)
            ds = New DataSet()
            da.Fill(ds)

How To Set a Date Format In GridView Using ASP.NET 2.0(Using HtmlEncode Property)

(AKA, the DataFormatString="{0:M-dd-yyyy}" Problem)


A very common desire is to set a column of a GridView to display just the month, day and year of a DateTime type. The problem is the by default, the HtmlEncode property of the BoundField attribute ( <asp:BoundField …) is set to True. The reason for this (as pointed out in the documentation of this

Retrieving Data Using the DataReader

You can use the ADO.NET DataReader to retrieve a read-only, forward-only stream of data from a database. Results are returned as the query executes, and are stored in the network buffer on the client until you request them using the Read method of the DataReader. Using the

Tuesday 20 September 2011

Email id validation


var at="@"
             var dot="."
              var lat=strEmail.indexOf(at)
              var lstr=strEmail.length var
             ldot=strEmail.indexOf(dot)

Monday 19 September 2011

What is the Main difference between String and StringBuilder and why do we use StringBuilder.


n Dot Net there will be many cases where in we need to operate on strings and first thing we remember is using system.String but there are certainly many points we need to remember and consider before we operate on strings.

Difference Between ToString() vs Convert.ToString() vs (string) cast


There is a simple but important difference between these three…
ToString() raise exception when the object is null