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 / July 2007

Tip: Looking for answers? Try searching our database.

asp.net page: Javascript not loading

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GroupReader - 03 Jul 2007 18:15 GMT
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
     LeftUpdatePanel
          Very large infragistics treeview

     RightUpdatePanel
         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
comments.
matthew.sibigtroth@gmail.com - 03 Jul 2007 18:42 GMT
I am new to asp.net so i could be way off...
Is it possible that since performace can take a major hit when
debug=true,
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
jojoba
Mark S. Milley, MCSD (BinarySwitch) - 03 Jul 2007 19:17 GMT
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,

-Mark
GroupReader - 03 Jul 2007 22:56 GMT
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 ==
true??

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.

Rate this thread:







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.