The problem is I want to be able to control the next control from
codebehind, based on operations done from codebehind (SQL calls etc).
The codebehind reads some server side textboxes and does some
calculations and checks some things on the back end, and depending on
the outcome, would setfocus to the appropriate control. It should be
able to do this by either registerclientside or startup script, or by
setting a hidden textbox with the setfocus javascript that the page
onload javascript calls with a javascript eval function. Basically, I
need some way for codebehind to indicate which control to go to to the
clientside javascript.
-------------------
This person had a similar problem, and had to do everything
javascript
:
From: Brian Watkins (raistlin19@aol.com)
Subject: Focus help needed
View this article only
Newsgroups: microsoft.public.dotnet.framework.aspnet
Date: 2003-06-19 13:22:16 PST
Hello,
When I type data into a text box and then exit it (via any means, tab,
click) i want to know how to make the focus go to the next logical
control.
I can set the focus to the correct text box initially by executing (In
Page_load or Page_Init) a subroutine called setfocus that contains the
document.getElementById javascript code. When I try to call the
setfocus
routine from the textchanged event of my text boxes it doesn't work.
It
appears that this has to do with the AutoPostBack being set for my
textboxes. For whatever reason ASP.net is determined to place the
focus
where it thinks the focus should be (usually the textbox that fired
the
autopostback) after a postback. Call me crazy but I would like to
have
full control over the focus in my app. It is unusable until I resolve
this.
Has anyone else had this problem or am I doing something foolish?
Any work
arounds known? Thanks for your help in advance!
Message 2 in thread
From: Trevor Hartman (synapsee@hotmail.com)
Subject: Re: Focus help needed
View this article only
Newsgroups: microsoft.public.dotnet.framework.aspnet
Date: 2003-06-19 13:40:10 PST
You should be able to control the focus of any items on the page, but
your
coding should be client side, not server side asp.net. You might also
want
to checkout the TABINDEX Attribute here:
http://msdn.microsoft.com/library/de...s/tabindex.asp
If you need more help with setting up some client side javascript let
me
know.
Trevor
"Brian Watkins" <raistlin19@aol.com> wrote in message
news:O9aUyAqNDHA.4024@tk2msftngp13.phx.gbl...[color=blue]
> Hello,
>
> When I type data into a text box and then exit it (via any means, tab,
> click) i want to know how to make the focus go to the next logical control.
> I can set the focus to the correct text box initially by executing (In
> Page_load or Page_Init) a subroutine called setfocus that contains the
> document.getElementById javascript code. When I try to call the setfocus
> routine from the textchanged event of my text boxes it doesn't work. It
> appears that this has to do with the AutoPostBack being set for my
> textboxes. For whatever reason ASP.net is determined to place the focus
> where it thinks the focus should be (usually the textbox that fired the
> autopostback) after a postback. Call me crazy but I would like to have
> full control over the focus in my app. It is unusable until I resolve this.
> Has anyone else had this problem or am I doing something foolish? Any work
> arounds known? Thanks for your help in advance!
>
>[/color]
Message 3 in thread
From: Brian Watkins (raistlin19@aol.com)
Subject: Re: Focus help needed
View this article only
Newsgroups: microsoft.public.dotnet.framework.aspnet
Date: 2003-06-20 05:47:55 PST
Thanks Trevor!
A Jscript example would be very helpful to me.
Say I have an .aspx page with two textboxes (txt1, txt2) and a label
(lblTotal).
When a number is typed into either of the text boxes I want to update
lblTotal with txt1.text + txt2.text and then shift the focus to the
other
textbox.
If you could show me a little client side jscript to do this I would
be
grateful. Thanks
Message 4 in thread
From: Brian Watkins (raistlin19@aol.com)
Subject: Re: Focus help needed
View this article only
Newsgroups: microsoft.public.dotnet.framework.aspnet
Date: 2003-06-23 07:18:13 PST
Thanks!
I guess that you have to manage focus with javascript. I wish that
Microsoft would have documented this better. I've wasted about a week
trying to manage the focus with server side code. All the advantages
of events and autopostbacks are dwindled considerably now. Not mush
use for asp.net may just go back to asp for server code and jscript
for
client side.
"Trevor Hartman" <synapsee@hotmail.com> wrote in message
news:eg8O0C0NDHA.1980@TK2MSFTNGP12.phx.gbl...
Hey Brian,
Try out the HTML doc I included and view its source.
Regards,
Trevor