473,804 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript in ASP.NET

7 New Member
Hello All,

I have implemented an Javascript inside an ASP.net page which raises an runtime error. "Object exspected". From wich I don't know what's the problem.
The Javascript is an external script imported into the project. I have put the following code in my codebehind file

Expand|Select|Wrap|Line Numbers
  1.         Page.RegisterStartupScript("PicitureSwitch", "<script language=javascript src='Images.js'>")
It stops at the following line:
Expand|Select|Wrap|Line Numbers
  1. <body bgcolor="#FFFFFF" onload="FP_preloadImgs(/*url*/'images/Product/19154816.jpg', /*url*/'images/Product/19154816.jpg')">
where the FP_preloadimgs is an function in the script.

This is the actual javascript:
Expand|Select|Wrap|Line Numbers
  1. <!--
  2.     function FP_swapImg() {//v1.0
  3.     var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
  4.      n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
  5.      elm.$src=elm.src; elm.src=args[n+1]; } }
  6. }
  7.  
  8. function FP_preloadImgs() {//v1.0
  9.  var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
  10.  for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
  11. }
  12.  
  13. function FP_getObjectByID(id,o) {//v1.0
  14.  var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
  15.  else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
  16.  if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
  17.  for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
  18.  f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
  19.  for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
  20.  return null;
  21. }
  22. // -->
Does anyone know what I am doing wrong?
Thank's in advance!!!
Dec 1 '08 #1
2 981
Plater
7,872 Recognized Expert Expert
Well I can tell you that this is wrong:
Page.RegisterSt artupScript("Pi citureSwitch", "<script language=javasc ript src='Images.js' >")

You could just stick this line in your aspx page:
<script language=javasc ript src='Images.js' />

That will include the javascript functions contained in the Images.js file. You can then call them out wherever you would like.

I would bet if you looked at your source code you would see some really funky nested <script lines
Jan 21 '09 #2
Frinavale
9,735 Recognized Expert Moderator Expert
Try using the Page.ClientScri pt.RegisterClie ntScriptInclude () to register your script include instead.

If your ASPX page is Ajax enabled (has a ScriptManager), you should register your script with the ScriptManager instead of the Page or Page.ClientScri pt.

-Frinny
Jan 22 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10352
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10097
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9175
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7642
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5535
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.