473,395 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

using linked .js file in UserControl

hi-

Has anyone found a way to use a linked .js file in a UserControl? I have a
control that has this line:
<script src="NSClientListBuilder.js"></script>

in that file is a function all test() test has a simple alert() call

I have a button on my usercontrol that will execute test(). Whenn the
script is in the ascx file, it works fine, when it's in a linked .js file I
get a script error. Has anyone and idea why this may be?

of course I have checked paths
filenames
etc

Thanks,
Steve
Nov 18 '05 #1
1 1546
I use scripts to enhance user controls regularly. When you say that you are
generating a script error, do you mean that the script is actually running?
If so, the issue could be with the fact that the user control will decorate
the names of the controls, so if you are trying to put in the ID of the
control only, ASP.NET will add on the name of the user control (which it
does to avoid name collisions - enabling you to have a textbox called "name"
on two different user controls, and still use both controls in a form), and
your script (if running) may simply no longer be able to find the objects
you are looking for. If you view source, you can see the actual names that
the runtime emits, or you could output the UniqueID property of the control
into a global variable (in a client side script block) to enable it to be
accessed.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"neverstill" <sk************@yahoo.com> wrote in message
news:OL**************@TK2MSFTNGP09.phx.gbl...
hi-

Has anyone found a way to use a linked .js file in a UserControl? I have a control that has this line:
<script src="NSClientListBuilder.js"></script>

in that file is a function all test() test has a simple alert() call

I have a button on my usercontrol that will execute test(). Whenn the
script is in the ascx file, it works fine, when it's in a linked .js file I get a script error. Has anyone and idea why this may be?

of course I have checked paths
filenames
etc

Thanks,
Steve

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access...
2
by: Ric | last post by:
im new to asp.net. from what i understand, you have the aspx file (presentation), user-control(ascx file), code-behind(vb file) and components(compiled vb and dll files). the aspx file contains a...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
1
by: Philipp Lenz | last post by:
I'm very confused about how this works, all the tutorials out there show me how to apply a skin to a webcontrol, but I want to know how I can access the components of a control....for example: I...
1
by: urs | last post by:
Two days ago, I built an ASP.NET 2.0 application and published it on a shared IIS 6 Web server. After publishing, and during the whole day, it worked fine. The server remained untouched since....
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
7
by: crowl | last post by:
VS.2003, .NET Framework 1.1, C# My goal: Creating a dll (helper.dll) which contains some UserControls and some other helpful classes in order to use it in other projects. Symtoms: The...
1
by: Paul | last post by:
Is there a special way to reference a Stylesheet (.css) in a usercontrol? I have a usercontrol in an aspx page.The aspx page itself has a Header Div, within which I put my UserControl.ascx. In the...
6
by: Rolf Welskes | last post by:
Hello, I want to partial cache by using a UserControl. Now I have a file dependency. In msdn I see it is not possible to do it the same way as in a page. The only information is to create a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.