Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > page: Javascript not loading

Thread Tools page: Javascript not loading

Posts: n/a
I posted a similar question earlier and got lots of good feedback, but
now I have more information:

Problem: I have javascript in a user control that is not "loading"
properly. When I try to call the script from my page, I get "object
not found".

Temporary Workaround: This only happens when I have "debug=true" in my
web.config. If I remove debug=true then then script works fine.

More info:
Here's the hierarchy of my entire page:

Master Page
Content Placehoder
Very large infragistics treeview

TabContainer User Control
Infragistics tab control - loads another UserControl
for each "tab"
Tab User Control
PROBLEM HERE: Script that is not loading
properly is way down here.

I can try to call a function that does "alert('hello');" and the
function is not found.
When I compile the application in release mode without debug=true, all
works fine.

What's going on?? Any ideas?? Thank you very much. I welcome all

Reply With Quote
Posts: n/a
I am new to so i could be way off...
Is it possible that since performace can take a major hit when
that your control isn't yet loaded when you try to access it?
Maybe make your program wait for a sec?
Just a shot in the dark

Reply With Quote
Mark S. Milley, MCSD (BinarySwitch)
Posts: n/a
Hi -

Take a look at the actual source your page is producing; is it
including the same javascript function multiple times?(once for each
instance of the control).

If so, this will also produce this error - you can't have more than
one JS function of the same name.

To get around this problem, you can either:

A) Generate the javascript dynamically, appending the ClientID to the
control after every reference of the function name (including the
function declaration)

B) Put the Javascript in a seperate file, and manually include this
file once on every page that uses your control. (do a search on client-
side includes)

Solution A is ideal if you plan on distributing the control amongst a
team or selling it. It's the better approach from a OOP point of view.
Unfortunately, by doing so, you end up with sloppy and overly verbose
HTML. Solution B) allows for cleaner output, but it might make you
scratch your head the next time you try to use this control.

You may be able to work with a third option wherein the controls
determine (through a shared variable, perhaps) whether or not there is
another control of the same type on the page, and whether or not the
client side include has already been written out, but that may be
more complicated than your project mandates.

Good Luck,


Reply With Quote
Posts: n/a
Awesome suggestions. Yep, I've tried all that.

Most code is in external files. The code that does not work is in the
page (user control) since it references page elements. I don't think
I have multiple copies of the functions loading since it fails on the
first time through.

.... And why would this only happen when compiled with debug mode ==

The only thing I'm embarrased to say that I haven't tried yet is to
view the actual source. "View source" will not work since this is all
in UpdatePanels and Infragistics tabs. I'll need to download
"Fiddler" to look at the data coming back.

Thanks for your suggestions.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
order of iframe loading with document loading ofir Javascript 0 12-03-2007 12:06 PM
loading image -> detect when image is done loading edfialk Javascript 0 05-10-2007 07:28 PM
[OT] Is loading the second Java application faster than loading the first? David Segall Java 2 01-02-2007 04:41 PM
Image loading using javascript. Handling timeouts and parrallel loading under IE Javascript 4 08-28-2005 02:02 PM
Stylesheet not Loading and Javascript Errors Before Refresh =?Utf-8?B?ZmJ3aGl0ZUBvbmxpbmUubm9zcGFt?= ASP .Net 3 01-07-2005 06:37 AM