January 2010

Date Comparision Javascript Validation

function ValidateDate()
var str1 = document.getElementById(“”).value;
var str2 = document.getElementById(“”).value;

var dt1 = parseInt(str1.substring(0,2),10);
var mon1 = parseInt(str1.substring(3,5),10);
var yr1 = parseInt(str1.substring(6,10),10);
var dt2 = parseInt(str2.substring(0,2),10);
var mon2 = parseInt(str2.substring(3,5),10);
var yr2 = parseInt(str2.substring(6,10),10);
var date1 = new Date(yr1, mon1, dt1);
var date2 = new Date(yr2, mon2, dt2);

if(date2 < date1)
alert("To date cannot be greater than from date");
return false;
return true;

Find Master Page Control In Content Page

  • Home
  • News

If I have understood this correctly…

If your list is on the master page…

  • Home
  • News

…then you can do this on your content page…

Control list = this.Page.Master.FindControl(“list”);

Then the li objects will be controls in the list object – e.g. list.Controls. Or you can do…

Control home = this.Page.Master.FindControl(“list”).FindControl(“home”);

…to find specific controls of the list control.

When using the runat=”server” on the HTML controls the server side equivalent object will be HtmlGenericControl.

If you want to apply a class to the LI tags what you would have to do is cast the LI object to a HtmlGenericControl and then use the Attributes property. For example…

HtmlGenericControl home = (HtmlGenericControl)this.Page.Master.FindControl(“list”).FindControl(“home”);

home.Attributes[“class”] = “className”;