Groups | Blog | Home
all groups > asp.net webcontrols > june 2004 >

asp.net webcontrols : ASPX , Placeholders and SET FOCUS



tob NO[at]SPAM sourcecode-inc.com
6/29/2004 10:52:36 AM
Hi,

How do SET FOCUS on a newly served (aspx) page to something that was
added into a [PLACEHOLDER] ?

I;ve tried typical Javascript and Page.RegisterStartup, but I get an
error saying that the object (say some "newTextBox1") does not exist !
But it will soon, right?

I've tried adding the script to the Page_Load, and Pre-Render in the
code-behind but with no success..but where else *could* it go??

The Webcontrols.Textbox at "add" time has properties such as "ID", but
not "set focus"

any ideas?

thanks,
ashelley NO[at]SPAM inlandkwpp.com
6/29/2004 7:01:18 PM
[quoted text, click to view]

put a label at the very bottom of the form. set its text property to
the javascript you want when u want it. The ensures that the
javascript will run last.

-Adam
Robert Koritnik
6/30/2004 10:34:59 AM
Could you PLEASE translate your suggestion to English language? I didn't get
your answer what exactly should be done... May be a good trick though.

--
RobertK
{ Clever? No just smart. }


[quoted text, click to view]

Robert Koritnik
6/30/2004 10:41:43 AM
Forget it. I think I "decoded" your answer...
Shouldn't BODY OnLoad do the trick, because the event won't fire until the
document is fully loaded. Injecting javascript code before that is not a
really smart idea...

--
RobertK
{ Clever? No just smart. }

[quoted text, click to view]

ashelley NO[at]SPAM inlandkwpp.com
6/30/2004 3:42:23 PM
On Wed, 30 Jun 2004 10:41:43 +0200, "Robert Koritnik"
[quoted text, click to view]

if it works why would it be so bad? i do it in my apps and it works
great. I set the visible tage on the label to false so when i want a
certain block of script to run i just set visible to true and boom.

there are a lot of ways to do most things. choose what is best for
u're app.

Robert Koritnik
7/1/2004 10:26:16 AM
I ran into a problem with this in some more "loaded" web app. What happened
was the nasty IE general fault that asks you about sending error to
wherever... Since then I avoid this technique. I rather use legal events
that work much more expectedly.

--
RobertK
{ Clever? No just smart. }

[quoted text, click to view]

AddThis Social Bookmark Button