Delete Text After Focus Change

 
More
 
More
 16th Jul 2008 09:51:00 AM

ric_the_red  
 
 delete text after focus change
 

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

 

{

newFieldName = strGridName +

el = document.getElementById(newFieldName).createTextRange();

 

returnValue =

}

 

}

if (colNum==0) "_ctl"+row+":_ctl"+nextCol;var PreText = el.text;false; break; //end of switch case

 

newTextBox = document.getElementById(newFieldName);

 

newTextBox.focus();

 

ReDo = document.getElementById(newFieldName).createTextRange();

alert(PreText);

ReDo.text = PreText;

 

if(null != newTextBox){if(null != PreText){

}

 

return returnValue;

 

 
More
 
  # 16th Jul 2008 10:00:51 AM

ric_the_red  
 
 

Sorry the code segment got mixed-up. Here is code I used:

//make column uneditable by moving focus                      
                if (colNum==0)
                    {
                    newFieldName = strGridName + "_ctl"+row+":_ctl"+nextCol;
                    el = document.getElementById(newFieldName).createTextRange();
                    var PreText = el.text;
                    returnValue = false;                     
                     }               
                break;          
           }    //end of switch case          
      
        newTextBox = document.getElementById(newFieldName);
        if(null != newTextBox){
            newTextBox.focus();

//PreText is text of new cell before focus change
            if(null != PreText){
                ReDo = document.getElementById(newFieldName).createTextRange();
                alert(PreText);
               ReDo.text = PreText;
             
            }
           return returnValue;
          
        }

 
More
 17th Jul 2008 05:30:10 AM

ric_the_red  
 
 

Found solution myself - in-case anyone else needs it in future:

added new attribute- "onKeyDown", "handleKey(" & _i & ")")"onmousemove", "handleMouse(" & _i & ")")

Mousemove shifts focus if column needs restricted. onKeyDown checks for shift + tab and moves focus 9:// Tab Key

 

//Catch shift tab attempt to move to 1st column

 

newFieldName = strGridName +

el = document.getElementById(newFieldName).createTextRange();

}

returnValue =

 

if (colNum==1 && event.shiftKey){"_ctl"+row+":_ctl"+nextCol;false;break;

case

 

e.Row.Attributes.Add(

e.Row.Attributes.Add(

 
Newsletter
Copyright © 2010 VisualBuilder. All rights reserved