scm0sml
asked on
setting focus after tabbing off a textbox in an update panel
Hi,
I have a number of controls inside an update panel.
When I tab off the first which has an autopostback=true, I run some code that goes off an hits the db, then sets the value of a literal control based on the results.
The problem is when I tab off, initially the cursor goes to the next textbox, however once the db hit has finished and the value of the literal gets set, the 2nd textbox then loses focus and the cursor is no longer where it should be.
I have tried adding txtInvCP.Focus() which is the 2nd textbox, inside the function that runs on the autopostback but still no joy, hopefully there is a way around this?
Thanks in advance.
I have a number of controls inside an update panel.
When I tab off the first which has an autopostback=true, I run some code that goes off an hits the db, then sets the value of a literal control based on the results.
The problem is when I tab off, initially the cursor goes to the next textbox, however once the db hit has finished and the value of the literal gets set, the 2nd textbox then loses focus and the cursor is no longer where it should be.
I have tried adding txtInvCP.Focus() which is the 2nd textbox, inside the function that runs on the autopostback but still no joy, hopefully there is a way around this?
Thanks in advance.
ASKER
wont that mean everytime the page loads the one specific textbox will be given focus?
yeah thats true, then set the RegisterEvent() function in the onchange event of the textbox that will trigger the database call
sample
==========
<asp:TextBox ID="TextBox3" onchange="RegisterEvent()" runat="server" AutoPostBack="True" OnTextChanged="TextBox3_Te xtChanged" ></asp:Tex tBox>
sample
==========
<asp:TextBox ID="TextBox3" onchange="RegisterEvent()" runat="server" AutoPostBack="True" OnTextChanged="TextBox3_Te
ASKER
seems as if the whole page is losing focus?
Your solution didn't work until I randomly put an alert('test'); before it, then once I have clicked the ok....the next textbox has focus...
Whatever this problem is is probably the reason it wasn't doing it initially does that sound right?
Any ideas?
Your solution didn't work until I randomly put an alert('test'); before it, then once I have clicked the ok....the next textbox has focus...
Whatever this problem is is probably the reason it wasn't doing it initially does that sound right?
Any ideas?
ASKER
Sorry when I say before it I mean:
function endRequestHandler(sender)
{
alert('HEY1');
document.getElementById('c tl00_mainc ontent_ucI nvoice_ucI nvoiceQuer y_txtInvCP ').focus() ;
}
function endRequestHandler(sender)
{
alert('HEY1');
document.getElementById('c
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Had no answers to fix this but found a solution myself.
<script type="text/javascript">
function RegisterEvent()
{
Sys.WebForms.PageRequestMa
}
function endRequestHandler(sender, args)
{
document.getElementById("<
}
</script>
<body onload="RegisterEvent()">