473,513 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript Src Ascx

I have a System.Web.UI.UserControl as custom control and
I have a javascript block for user control. The problem
is I want to bring src attribute from outside as property
or other method.

e.g <script language="JavaScript"
src="Scripts/filename.js"></script>

When I register this control (drop control) on aspx page
different than current folder in other words, when I have
aspx page few level down from root asp.net application
the src attribute does not work. Any ideas.... I am
really new to asp.net

Nov 18 '05 #1
2 2578
Got a few questions:
1. Are you try to reference to a javascript file from the webform or
the web user control?

2. Could you give more details in how you layout your webform and web
user control? For example, where are the webform, web user control,
and the javascript file located?

It's most likely that you have the script placed in the wrong
location. When you load a user control to a webform, the user control
is running under the location of the webform, so the javascript's
relative path is based on the webform's location.

For example,

(Folder1)
WebForm
(Folder2)
Web user control

The relative path for the javascript will be

/Folder1/Scripts

not

/Folder1/Folder2/Scripts

Tommy,

"New User" <an*******@discussions.microsoft.com> wrote in message news:<11****************************@phx.gbl>...
I have a System.Web.UI.UserControl as custom control and
I have a javascript block for user control. The problem
is I want to bring src attribute from outside as property
or other method.

e.g <script language="JavaScript"
src="Scripts/filename.js"></script>

When I register this control (drop control) on aspx page
different than current folder in other words, when I have
aspx page few level down from root asp.net application
the src attribute does not work. Any ideas.... I am
really new to asp.net

Nov 18 '05 #2
Tommy,

I am trying to use Script file in Web User control. some
one suggested to use property but this script file is in
html code behind window.

Web User contol has <script language="JavaScript"
src="Scripts/filename.js"></script>
in HTML code behind and not in Design or code behind .cs
file.

I do not do anything in webform about javascript file. I
will try a public property.

Thank you
-----Original Message-----
Got a few questions:
1. Are you try to reference to a javascript file from the webform orthe web user control?

2. Could you give more details in how you layout your webform and webuser control? For example, where are the webform, web user control,and the javascript file located?

It's most likely that you have the script placed in the wronglocation. When you load a user control to a webform, the user controlis running under the location of the webform, so the javascript'srelative path is based on the webform's location.

For example,

(Folder1)
WebForm
(Folder2)
Web user control

The relative path for the javascript will be

/Folder1/Scripts

not

/Folder1/Folder2/Scripts

Tommy,

"New User" <an*******@discussions.microsoft.com> wrote

in message news:<110301c3b443$64625400
$a*******@phx.gbl>...
I have a System.Web.UI.UserControl as custom control and I have a javascript block for user control. The problem is I want to bring src attribute from outside as property or other method.

e.g <script language="JavaScript"
src="Scripts/filename.js"></script>

When I register this control (drop control) on aspx page different than current folder in other words, when I have aspx page few level down from root asp.net application
the src attribute does not work. Any ideas.... I am
really new to asp.net

.

Nov 18 '05 #3

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

Similar topics

0
6414
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
1
5398
by: Jorge Ponte | last post by:
hi I have a Web User Control (ascx) - lets call it "My_WUC" - in a Web form. In that WUC I want have a textbox and a button. I want to click on the button and open a popup (I use javascript for...
3
2817
by: Peter | last post by:
Hello, We are inserting a side menu to our application using a class that is writing HTML on all our pages. This is a part of the code as an example: writer.Write(" <table WIDTH=""100%""...
4
5208
by: E | last post by:
I am having trouble with setTimeout working on a second call to the setTimeout function from a second page which is an html page. Here is the scenario. I have a web page and onload it calls a...
0
982
by: rockdale | last post by:
I have an aspx file and a placeholder to dynamic load user defined webcontrols (ascx) in one one my user defined webcontrols, I need to call functions in my js file. I put the following line in...
0
1848
by: acadam | last post by:
Hi, I have an userControl .ascx with a gridView control. One of the columns is a TemplateField with an HyperLink control. On the Row_DataBound event, I am checking that one of the other columns...
0
1587
by: Brett Wesoloski | last post by:
I am trying to put javascript in an .ascx file. Although it seems to work no compile errors the button does nothing. This is what I have. In my grid a template column. Then above in the .ascx...
0
1236
by: mpl | last post by:
Hi, i have an ascx file haivng code like <asp:LinkButton ID="col" runat="server" Text='<%# Eval("8Y") %>' OnClick="ColSelected" /> now i am using code behind implmentation for ColSelected.I...
7
11889
by: mpl | last post by:
Hi, i have an ascx file(web control file ) haivng code like <asp:LinkButton ID="col" runat="server" Text='<%# Eval("8Y") %>' OnClick="ColSelected" /> now i am using code behind implmentation...
2
3006
by: mpl | last post by:
Hi, i have an ascx file named mytestcontrol.ascx. it has reference to another ascx control as below. <%@ Register Src="myControl.ascx" TagName="myControl" TagPrefix="uc" %> .... .........
0
7265
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
7171
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
7388
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,...
1
7111
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...
0
7539
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...
0
4751
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...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1605
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 ...
1
807
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.