Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. JavaScript in MasterPages [asp.net 2.0]

JavaScript in MasterPages [asp.net 2.0]

Scheduled Pinned Locked Moved ASP.NET
helpcsharpjavascriptasp-nettools
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    student_rhr
    wrote on last edited by
    #1

    As long as MasterPage and WebForm are in the same directory the JavaScript file works but when the directories are different I get javascript error cuz the file was not found. I tried to google this problem and found that if you put the script block within the < HEAD >, ASP.NET 2.0 runtime will resolve the URL but for some odd reason that is not the case here. Here is how I am doing it: the file is inside a folder called JavaScript which is right under root folder. I tried this first:

    Then I tried this:

    Then I tried this, but I got an ugly error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

     type="text/javascript">
    

    Can someone tell me how to take care of this problem:confused:. Thanks in advance. -- modified at 8:58 Thursday 4th May, 2006

    R G 3 Replies Last reply
    0
    • S student_rhr

      As long as MasterPage and WebForm are in the same directory the JavaScript file works but when the directories are different I get javascript error cuz the file was not found. I tried to google this problem and found that if you put the script block within the < HEAD >, ASP.NET 2.0 runtime will resolve the URL but for some odd reason that is not the case here. Here is how I am doing it: the file is inside a folder called JavaScript which is right under root folder. I tried this first:

      Then I tried this:

      Then I tried this, but I got an ugly error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

       type="text/javascript">
      

      Can someone tell me how to take care of this problem:confused:. Thanks in advance. -- modified at 8:58 Thursday 4th May, 2006

      R Offline
      R Offline
      R Prabha Devi
      wrote on last edited by
      #2

      Hi, Try below code,

      Hope it works...:)

      S 1 Reply Last reply
      0
      • S student_rhr

        As long as MasterPage and WebForm are in the same directory the JavaScript file works but when the directories are different I get javascript error cuz the file was not found. I tried to google this problem and found that if you put the script block within the < HEAD >, ASP.NET 2.0 runtime will resolve the URL but for some odd reason that is not the case here. Here is how I am doing it: the file is inside a folder called JavaScript which is right under root folder. I tried this first:

        Then I tried this:

        Then I tried this, but I got an ugly error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

         type="text/javascript">
        

        Can someone tell me how to take care of this problem:confused:. Thanks in advance. -- modified at 8:58 Thursday 4th May, 2006

        R Offline
        R Offline
        R Prabha Devi
        wrote on last edited by
        #3

        Hi, Try below code,

        Hope it works..:)

        1 Reply Last reply
        0
        • R R Prabha Devi

          Hi, Try below code,

          Hope it works...:)

          S Offline
          S Offline
          student_rhr
          wrote on last edited by
          #4

          Thanks for the reply, but

          does not work.

          1 Reply Last reply
          0
          • S student_rhr

            As long as MasterPage and WebForm are in the same directory the JavaScript file works but when the directories are different I get javascript error cuz the file was not found. I tried to google this problem and found that if you put the script block within the < HEAD >, ASP.NET 2.0 runtime will resolve the URL but for some odd reason that is not the case here. Here is how I am doing it: the file is inside a folder called JavaScript which is right under root folder. I tried this first:

            Then I tried this:

            Then I tried this, but I got an ugly error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

             type="text/javascript">
            

            Can someone tell me how to take care of this problem:confused:. Thanks in advance. -- modified at 8:58 Thursday 4th May, 2006

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            Check if the framework resolves this: <script src="~/Javascript/x.js" type="text/javascript"></script> --- b { font-weight: normal; }

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups