Javascript Src Ascx

  • Thread starter Thread starter New User
  • Start date Start date
N

New User

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
 
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,
 
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 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" <[email protected]> wrote
in message [email protected]>...
 
Back
Top