Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

elements not loaded before RegisterStartupScript

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Crazy Cat - 24 Aug 2007 23:19 GMT
In the page load event of my user control I create and register a
startup script with RegisterStartupScript. I am passing two controls
(using the ClientID property of the controls) into a function in the
startup script and I get
an undefined error on one of them (an image control) while the other
(a div) is found with no problem. Additionally even
if I comment out all references to the undefined control (except the
in the argument list for the function) I get the undefined error and
the function does not run. What the hell -- why should it stop with an
undefined argument if the argument is not used?

Please HELP!!!!
Nathaniel Greene - 25 Aug 2007 03:36 GMT
You may wish to use Firebug  and Firefox together to debug this , however in
regards to the objects not loading before the script executes - you either
need to push the script to be rendered at the end of the page, subscribe to
the body's onload event and do your stuff there or have a setTimeout that
tries to get the element , if it's null then wait naother 500-1000
milliseconds and check again.
Ideally - you're probably gonna be better off subscribing to the body's
onload event.

> In the page load event of my user control I create and register a
> startup script with RegisterStartupScript. I am passing two controls
[quoted text clipped - 8 lines]
>
> Please HELP!!!!
Muhammad Naveed Yaseen - 25 Aug 2007 23:52 GMT
Images usually have natural latency of being loaded later than
document. Put startup script instead in onload event of image like
<img onload="javascript:startup(x,y);" .... /> (or if server-side
Image control then ImageXyz.Attributes["onload"] =
"javascript:startup(x,y);";
Crazy Cat - 27 Aug 2007 15:59 GMT
> Images usually have natural latency of beingloadedlater than
> document. Put startup script instead in onload event of image like
> <img onload="javascript:startup(x,y);" .... /> (or if server-side
> Image control then ImageXyz.Attributes["onload"] =
> "javascript:startup(x,y);";

This code is going to be in a user control. If I subscribe to the
form's body onload event what if the parent page has its body onload
event already specified? Wouldn't that
render either my control's body.onload event useless or the parent
page's onload event useless?

I tried to do this in the onload event for the image but the script is
still loading before the image (this is being handled server-side
since the clientside image control does not handle an onload event).

Much as I hate it it looks like I'll have to implement Yaseen's
solution and wait and check for the image to be loaded.

Thanks,

Dan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.