How to do read only true in any calendar extender on the basic of dynamic condation . please analysis this code where we can add this function.
<script type="text/javascript">
function HighlightDates() {
var cal = $find("jtxb_Date_CalendarExtender");
//debugger;
if (cal != null) {
//Add handlers to the Arrows and the table header so that if these are used then it rescans the calendar. Otherwise the Cells retain the coloring
addMyHandler(cal._prevArrow);
addMyHandler(cal._nextArrow);
addMyHandler(cal._header);
//Start the initial scan
processDates();
$("#jtxb_Date_CalendarExtender_prevArrow").click(function () {
// debugger;
var cal = $find("jtxb_Date_CalendarExtender");
if (cal != null) {
//Scan each of the Calendar screens passing throught the date format to look for
ColourCells(cal._daysBody, "dddd, MMMM dd, yyyy", cal._mode);
ColourCells(cal._monthsBody, "MMMM, yyyy", cal._mode);
ColourCells(cal._yearsBody, "<BR>yyyy", cal._mode);
}
});
$("#jtxb_Date_CalendarExtender_nextArrow").click(function () {
//debugger;
var cal = $find("jtxb_Date_CalendarExtender");
if (cal != null) {
//Scan each of the Calendar screens passing throught the date format to look for
ColourCells(cal._daysBody, "dddd, MMMM dd, yyyy", cal._mode);
ColourCells(cal._monthsBody, "MMMM, yyyy", cal._mode);
ColourCells(cal._yearsBody, "<BR>yyyy", cal._mode);
}
});
}
}
//This is the secondary function that is called while the calendar is open when any of the cells are clicked
function processDates() {
//debugger;
var cal = $find("jtxb_Date_CalendarExtender");
if (cal != null) {
//Scan each of the Calendar screens passing throught the date format to look for
ColourCells(cal._daysBody, "dddd, MMMM dd, yyyy", cal._mode);
ColourCells(cal._monthsBody, "MMMM, yyyy", cal._mode);
ColourCells(cal._yearsBody, "<BR>yyyy", cal._mode);
}
}
//This returns a string with all of the dates formatted
function formatDates(dateFormat) {
//debugger;
var formattedDates = "dates";
//var hf_Dateofcommence = document.getElementById("hf_Dates");
var hf_Dateofcommence = document.getElementById('<%=hf_Dates.ClientID%>')
//Split the comma seperated dates into an array
var dateArray = hf_Dateofcommence.value.split(',');
//loop through the date array and return a formatted date
for (a in dateArray) {
//Split the date into an array
var myYMD = dateArray[a].toString().split("-");
//Get the year month and day (if you want to change the date format then you will need to change these around
var myYear = parseInt(myYMD[0].toString(), 10);
var myMonth = parseInt(myYMD[1].toString(), 10) - 1;
var myDay = parseInt(myYMD[2].toString(), 10);
//Get the formatted date
var myDate = new Date(myYear, myMonth, myDay).format(dateFormat);
//Only add new formatted dates to the return string
if (formattedDates.indexOf(myDate) == -1) {
formattedDates = formattedDates + "," + myDate;
}
}
return formattedDates;
}
//This is the function that scans the Calendar screen
function ColourCells(obj, dateFormat, calMode) {
//debugger;
//var hf_colors = document.getElementById("hf_color");
var hf_colors = document.getElementById('<%=hf_color.ClientID%>')
var colorArray = hf_colors.value.split(',');
var xt = 0
var formattedDates = formatDates(dateFormat);
//Loop through each of the Rows
for (var i = 0; i < obj.rows.length; i++) {
//Loop through each of the cells
for (var j = 0; j < obj.rows[i].cells.length; j++) {
var cell = obj.rows[i].cells[j];
var match = 0;
//If the Screen is years then there is no Tool tip so you have to use the text in the cell and this includes the html <BR> tag
//other wise use the tooltip
if ((calMode == "years" && formattedDates.indexOf(cell.firstChild.innerHTML) > -1)
|| (calMode != "years" && formattedDates.indexOf(cell.firstChild.title) > -1)) {
if (colorArray[xt] == "1") {
cell.style.backgroundColor = "Red";
cell.style.color = "White";
} else {
cell.style.backgroundColor = "Green";
cell.style.color = "White";
}
match++;
xt++;
}
else {
cell.style.backgroundColor = "white";
cell.style.color = "Black";
}
//Add the handler to the cell
addMyHandler(cell.firstChild);
}
}
}
//Add a handler so that it rescans
function addMyHandler(i) {
//delete it if it is all ready there
try {
Sys.UI.DomEvent.removeHandler(i, "blur", processDates);
}
catch (exception) {
}
Sys.UI.DomEvent.addHandler(i, "blur", processDates);
}
</script>