Writing Javascript to end of page

M

Mark

Hi - I have a component, which sends some Javascript to the page.

I have a registerclientscriptblock which writes some Javascript which
when the page is loaded, references a textbox written to the page by the
component.

However, my javascript gets written to the page before the components
javascript, so when my script runs, the textbox being referenced doesn't
exist yet.

Is there any way to ensure my script, written by the
registerclientscriptblock, gets written to the end of the page, after
all other javascript?

Thanks, Mark
 
K

Karsten Samaschke [MVP]

Hi,

You don't need a script at the end of the page, but a script which is
executed after the page loads:

window.onload = function() {
// JavaScript-Code goes here and is executed *after* the page
loads...
}

--
Karsten Samaschke
IT-Consulting, IT-Development, IT-Training
5x MS MVP ASP / ASP.NET, Germany
Homepage: http://www.ksamaschke.de
Weblog: http://www.karsan.de
- - - - - - - - - - - - - - - - - - - - - - - - - -
My Weblog: http://www.karsan.de
My Books: http://books.ksamaschke.de
 
K

Karl Seguin

Use RegisterStartupScript instead, which does (and is meant to do) exactly
what you want :)

karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top