Check whether date is valid or not

Tuesday, June 29, 2010

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ApplyNow : System.Web.UI.Page
{
    private String dob;

protected void btn_applyNow_Click(object sender, EventArgs e)
    {
        if (getDob())
        {
            if (isAvailable(txt_emailAddress.Text))
                insertStudent();

            else
                lbl_error.Text = "Email already exists";
        }

        else
        {
            lbl_error.Text = "Please enter valid date";
        }
    }

private bool getDob()
    {
        dob = ddl_month.SelectedValue + " " + ddl_day.SelectedValue + ", " + 
        ddl_year.SelectedValue;

        try
        {
            DateTime.Parse(dob);
            return true;
        }

        catch
        {
            return false;
        }
    }

 private void insertStudent()
    {
         //coding    
    }
 }

**************************LINKS******************************

I have created a new better blog:

My Youtube channel:

**************************LINKS******************************

C# Dynamic DropDownList of Year

Thursday, June 24, 2010

private void fillDropdown()
    {
        int year = DateTime.Now.Year;
        year -= 1;

        for (int i = 0; i <= 100; i++)
        {
            ddl_year.Items.Add(year.ToString());
            year--;
        }
    }


**************************LINKS******************************

I have created a new better blog:

My Youtube channel:

**************************LINKS******************************

Get Internal IP of machine in C#

Saturday, June 5, 2010

//other related namespaces
using System.Net;

//this is example class, you can code it in your own way
public class getIP : System.Web.UI.Page
{
     //other related coding
     IPHostEntry IPHost = Dns.GetHostEntry(Dns.GetHostName());
     String ip = IPHost.AddressList[0].ToString();
}

**************************LINKS******************************

I have created a new better blog:

My Youtube channel:

**************************LINKS******************************

SQL Server: Insert records from .txt file

Thursday, June 3, 2010


CREATE TABLE geoip (
  start_ip CHAR(15) NOT NULL,
  end_ip CHAR(15) NOT NULL,
  start_long INT NOT NULL,
  end_long INT NOT NULL,
  country_code CHAR(2) NOT NULL,
  country_name VARCHAR(50) NOT NULL);


BULK INSERT geoip
 FROM 'd:\geoip.txt'
  WITH
  (
      FIELDTERMINATOR = ',',
      ROWTERMINATOR = '\n'
  )



Download 'geoip.txt' here

**************************LINKS******************************

I have created a new better blog:

My Youtube channel:

**************************LINKS******************************