Javascript Src Ascx

Discussion in 'ASP .Net' started by New User, Nov 26, 2003.

  1. New User

    New User Guest

    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
    New User, Nov 26, 2003
    #1
    1. Advertising

  2. New User

    Tommy Guest

    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" <> wrote in message news:<110301c3b443$64625400$>...
    > 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
    Tommy, Nov 27, 2003
    #2
    1. Advertising

  3. New User

    New User Guest

    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" <> wrote

    in message news:<110301c3b443$64625400
    $>...
    >> 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

    >.
    >
    New User, Dec 1, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Richter

    <txt src= ...> equivalent of <img src= ...>

    Steve Richter, Feb 8, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,083
    Laurent Bugnion
    Feb 9, 2006
  2. Greg Johnson
    Replies:
    4
    Views:
    3,070
  3. Replies:
    1
    Views:
    1,618
    Alex Hunsley
    Mar 23, 2007
  4. pheadxdll
    Replies:
    16
    Views:
    3,668
    Neredbojias
    Jun 6, 2007
  5. New User

    JavaScript Src attrubute in ascx

    New User, Nov 26, 2003, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    149
    New User
    Dec 1, 2003
Loading...

Share This Page