473,657 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="NSClientLi stBuilder.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 1552
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******** ******@TK2MSFTN GP09.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="NSClientLi stBuilder.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
3150
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 the code variable that are supposed to be linked to the contained controls. It runs fines when everything is contained in a single web form project. What do I need to do to make it work from a class library?
2
3097
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 reference to the ascx which can contain a reference to a component. can an aspx file contain a reference to an ascx file which contains a reference to a code-behind file? ive tried to do this then load the user-control via LoadControl(), but i...
2
3436
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: //Page_load of my user control protected void Page_Load(object sender, EventArgs e) { IDataItemContainer DataContainer = this.Parent as
1
3013
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 have a usercontrol, the ascx is defined like this: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Test.ascx.cs" Inherits="Spin.Test" %> <asp:Panel ID="Panel1" runat="server" Height="243px" Width="350px">
1
10787
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. Today, I wanted to access the home page of the application again with a browser. But instead of the proper page, I just got an ugly message: Server Error in '/' Application.
12
2198
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 server. It "serves" back the required control (either WebControl or UserControl) based on the contents of an xml file. The code in the webform places each control in a TableCell. My problem is that the control server works as far as returning the...
7
3161
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 inital use of the UserControl component works. However, if the Helper Project is recompiled, the UserControl does not work
1
8785
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 UserControl I want to use DIVS only, just to make work easier at a future point. So, I have an outer Div called HeaderContainer, and then some contained divs. If this were just an aspx page, then all the rendering is fine, but when I try to do...
6
2752
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 file dependency and assign it to Dependency property.
0
8385
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8303
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
8821
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
8723
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
8602
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
7316
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...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2726
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
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.