I have a gridview I am using some javascript to make a column un-editable (the built in editable=false does not suit my needs). My work around is to move focus to the next cell on keydown. This works fine but the key the user enters is entered into the new cell. I don't want the key passed after the focus move, or delete it immediately after the focus change. My code extract is below. I capture the new cell's text before moving focus to it then I set the new cell's text to what it was before focus change. But the entered keystroke is added at end regardless of where I place the .focus(). Is there any other way to move focus on keydown and not pass the key to the new focus location? Or to delete the passed key after focus change?
//make column uneditable by moving focus
if (colNum==0)
{
newFieldName = strGridName + "_ctl"+row+":_ctl"+nextCol;
el = document.getElementById(newFieldName).createTextRa nge();
var PreText = el.text; //capture new cell's text before focus
returnValue = false;
}
break;
} //end of switch case
newTextBox = document.getElementById(newFieldName);
if(null != newTextBox){
newTextBox.focus(); //move focus
if(null != PreText){
ReDo = document.getElementById(newFieldName).createTextRa nge();
alert(PreText);
ReDo.text = PreText; //set text to what it was earlier
}
return returnValue;
}
