external js file with masterpage

Discussion in 'ASP .Net' started by Stan SR, Aug 14, 2006.

  1. Stan SR

    Stan SR Guest

    Hi,

    I use a masterpage for all my project.
    For some pages I have some external javascript file that I would like to
    include.
    How can I do this action from the content pages ?

    Stan
     
    Stan SR, Aug 14, 2006
    #1
    1. Advertising

  2. From individual pages, this is simple. Just link to the JavaScript. From the
    master page, it is more difficult, as the JavaScript linking does not
    respect the ResolveClientUrl() for some reason. Either that, or I have not
    found the magic.

    Put the links in teh pages you need, or create a page object that has the
    link and inherit from it.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    *************************************************
    Think Outside the Box!
    *************************************************
    "Stan SR" <> wrote in message
    news:%238wtFL$...
    > Hi,
    >
    > I use a masterpage for all my project.
    > For some pages I have some external javascript file that I would like to
    > include.
    > How can I do this action from the content pages ?
    >
    > Stan
    >
     
    Cowboy \(Gregory A. Beamer\), Aug 15, 2006
    #2
    1. Advertising

  3. Stan SR

    Pavel Prchal Guest

    Stan SR napsal(a):
    > Hi,
    >
    > I use a masterpage for all my project.
    > For some pages I have some external javascript file that I would like to
    > include.
    > How can I do this action from the content pages ?
    >
    > Stan
    >
    >

    Try following code(in masterpage's OnLoad)

    protected string m_sScript = "MasterPageRoot/MasterPageScript.js";

    .....
    string sPrefix = string.Empty;
    if (Request.AppRelativeCurrentExecutionFilePath.IndexOf("inner-folder")
    > -1)

    sPrefix = "../";

    this.DataBind();

    .... and in masterpage
    <script src="<%#m_sScript%>" type="text/javascript">

    Pavel
     
    Pavel Prchal, Aug 15, 2006
    #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. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    MasterPage -> Page -> MasterPage Code Access

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Apr 10, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    7,922
    Steven Cheng[MSFT]
    Apr 14, 2006
  2. ThunderMusic
    Replies:
    2
    Views:
    463
    Gregory Gadow
    Sep 27, 2006
  3. Randy Smith
    Replies:
    9
    Views:
    450
    Mark Rae
    Apr 14, 2007
  4. mr t
    Replies:
    0
    Views:
    417
  5. Torben Laursen
    Replies:
    4
    Views:
    586
    clintonG
    Mar 15, 2008
Loading...

Share This Page