Hello all...I'm new to the board. I have a problem that I hope someone here
might be able to solve for me.
I am doing some clientside validation using Javascript. The text I am
testing is within a textbox that is part of a datagrid. To complicate
things, the datagrid is part of a user control. The following code is all
part of the user control.
The validation part of the script works fine. However, when I try to set
the focus back to the offending textbox, I have problems.
The validation, naturally enough, is called from the 'onchange event'. When
rendered, the text box looks like this:
<td align="Right"><input name="ucControl:dgGrid:_ctl2:MY_TEXT" type="text"
value="0.00" maxlength="7" id="ucControl_dgGrid__ctl2_MY_TEXT"
class="MyClass" onchange="Validate_It(this);" style="width:55px;" /></td>
The JavaScript I'm using is:
function Validate_It(obj){
....<Your validation code ending in failure here>...;
window.alert(obj.id);
obj.focus();
}
This function pops up a messagebox when an error occurs, but does not set
the focus to the offending object. I should note that this coding works fine
outside of a datagrid/user control.
I've tried several other things that I guessed might work, most notably
replacing 'obj.focus()' with:
document.getElementByName(obj.Name).focus();
This not only didn't work, but also returned the browser error:
'Object doesn't support this property or method'
I'm now officially stymied. Is there something about the Datagrid control
that I'm missing here? Or might the problem lay in the fact that his is a
User Control?
Any help would be appreciated.
My thanks in advance,
ED M.