J
jdp
I have an editable datagrid as part of a usercontrol. When I click the
Edit button, I wish for focus to be set on the first control, a
dropdownlist. I have underlying javascript that I found elsewhere here
but it does not appear to work.
<script language="javascript">
<!--
frm.myComponents_dgdEdit__ctl2_txtBox.focus();
frm.myComponents_dgdEdit__ctl2_txtBox.select();
//-->
</script>
"myComponents_dgdEdit__ctl2_txtBox" is retrieved by FindControl and
using the ClientID property.
I placed this code in a string variable, strScript, and then performed
CType(sender, DataGrid).Parent.Page.RegisterStartupScript("focus",
strScript)
all within the 'OnItemComand' sub that is defined for the grid.
I have also tried
document.getElementById('myComponents_dgdEdit__ctl2_txtBox').focus();
to no avail. What I found equally as puzzling is that while the focus
was not set, the data in the textbox was selected telling me the
..select() worked.
If someone could point me in the right direction or tell me what I'm
doing wrong, I'd appreciate it!
Any feedback would be appreciated.
Edit button, I wish for focus to be set on the first control, a
dropdownlist. I have underlying javascript that I found elsewhere here
but it does not appear to work.
<script language="javascript">
<!--
frm.myComponents_dgdEdit__ctl2_txtBox.focus();
frm.myComponents_dgdEdit__ctl2_txtBox.select();
//-->
</script>
"myComponents_dgdEdit__ctl2_txtBox" is retrieved by FindControl and
using the ClientID property.
I placed this code in a string variable, strScript, and then performed
CType(sender, DataGrid).Parent.Page.RegisterStartupScript("focus",
strScript)
all within the 'OnItemComand' sub that is defined for the grid.
I have also tried
document.getElementById('myComponents_dgdEdit__ctl2_txtBox').focus();
to no avail. What I found equally as puzzling is that while the focus
was not set, the data in the textbox was selected telling me the
..select() worked.
If someone could point me in the right direction or tell me what I'm
doing wrong, I'd appreciate it!
Any feedback would be appreciated.