Javascript problem in Custom Webcontrol

Discussion in 'ASP .Net Building Controls' started by New User, Dec 2, 2003.

  1. New User

    New User Guest

    I have following structure for my project


    myproj
    Controls/control1
    morepages/special.aspx
    specialpages/webpage1.aspx
    scripts/filename.js
    default.aspx



    I have a control1 which has a public property name
    ScriptFilePath for bring in external javascript file.

    E.g it works for when I use control in default.aspx using
    ScriptFilePath="Scripts/filename.js"
    ok when i click on link to navigate it goes to for
    example, morepages/special.aspx page.

    However,

    When I use same control in webpage1.aspx with
    ScriptFilePath="../Scripts/filename.js" then
    I click on link in webpage1.aspx it produces following
    path myproj/specialpages/morepages/special.aspx rather
    than morepages/special.aspx.


    any ideas


    Thanks in advance
     
    New User, Dec 2, 2003
    #1
    1. Advertising

  2. Try using the Tilde like so:
    ScriptFilePath="~/Scripts/filename.js"

    "New User" <> wrote in message
    news:07b801c3b8fc$d09c9d20$...
    > I have following structure for my project
    >
    >
    > myproj
    > Controls/control1
    > morepages/special.aspx
    > specialpages/webpage1.aspx
    > scripts/filename.js
    > default.aspx
    >
    >
    >
    > I have a control1 which has a public property name
    > ScriptFilePath for bring in external javascript file.
    >
    > E.g it works for when I use control in default.aspx using
    > ScriptFilePath="Scripts/filename.js"
    > ok when i click on link to navigate it goes to for
    > example, morepages/special.aspx page.
    >
    > However,
    >
    > When I use same control in webpage1.aspx with
    > ScriptFilePath="../Scripts/filename.js" then
    > I click on link in webpage1.aspx it produces following
    > path myproj/specialpages/morepages/special.aspx rather
    > than morepages/special.aspx.
    >
    >
    > any ideas
    >
    >
    > Thanks in advance
    >
     
    Stanley Glass, Jan 5, 2004
    #2
    1. Advertising

  3. You can also use ../ to go up one level and then traverse to the
    appropriate directory where the javascript file resides.

    Hope this helps.

    Imtiaz Hussain.

    This posting is provided "as is" with no warranties and confers no rights.
     
    Imtiaz Hussain, Jan 8, 2004
    #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. Guest
    Replies:
    2
    Views:
    744
  2. Luis Ramírez.

    Can a webcontrol (webcontrol.dll) have a configuration file?

    Luis Ramírez., Jul 5, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    210
    Luis Ramírez
    Jul 6, 2004
  3. Kasabaarde Sumta

    WebControl inside of WebControl and attaching events

    Kasabaarde Sumta, Dec 13, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    204
    Kasabaarde Sumta
    Dec 13, 2004
  4. Fabricio

    Custom webcontrol that references another webcontrol

    Fabricio, Sep 21, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    192
    Fabricio
    Sep 21, 2005
  5. Curt_C [MVP]

    Custom WebControl, custom property list

    Curt_C [MVP], Sep 1, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    187
    Curt_C [MVP]
    Sep 1, 2005
Loading...

Share This Page