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. how to include .js file for one page using master page?

how to include .js file for one page using master page?

Scheduled Pinned Locked Moved ASP.NET
javascripthelptutorialquestion
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.
  • V Offline
    V Offline
    vicky457
    wrote on last edited by
    #1

    Hi, I want to include a .js file only for one particular page which is using master page. Since the .js file is very large and only for this particular page, I don't want to include it in Master page. Because it will add into every page that is using the master page. Also, I dont' want to convert all the functions in .js file into string to register through RegisterClientScriptEvent, again, because the functions are too long to convert. Is there a way to do it by NOT using the ways mentioned above? Any help would be appreciated! Thanks!

    G I 2 Replies Last reply
    0
    • V vicky457

      Hi, I want to include a .js file only for one particular page which is using master page. Since the .js file is very large and only for this particular page, I don't want to include it in Master page. Because it will add into every page that is using the master page. Also, I dont' want to convert all the functions in .js file into string to register through RegisterClientScriptEvent, again, because the functions are too long to convert. Is there a way to do it by NOT using the ways mentioned above? Any help would be appreciated! Thanks!

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

      Add the tag to the Page.Header.Controls collections. I don't think that there is a class for the script tag, so you have to use HtmlGenericControl to make one.

      --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • V vicky457

        Hi, I want to include a .js file only for one particular page which is using master page. Since the .js file is very large and only for this particular page, I don't want to include it in Master page. Because it will add into every page that is using the master page. Also, I dont' want to convert all the functions in .js file into string to register through RegisterClientScriptEvent, again, because the functions are too long to convert. Is there a way to do it by NOT using the ways mentioned above? Any help would be appreciated! Thanks!

        I Offline
        I Offline
        indianet
        wrote on last edited by
        #3

        try ClientScriptManager.RegisterClientScriptInclude.

        V 1 Reply Last reply
        0
        • I indianet

          try ClientScriptManager.RegisterClientScriptInclude.

          V Offline
          V Offline
          vicky457
          wrote on last edited by
          #4

          I did use RegisterClientScriptInclude to make it work. But I try to pass Form1 into Javascript function , it won't let me do it. Note, Form1 is form from master page. Any idea? Thanks!

          G 1 Reply Last reply
          0
          • V vicky457

            I did use RegisterClientScriptInclude to make it work. But I try to pass Form1 into Javascript function , it won't let me do it. Note, Form1 is form from master page. Any idea? Thanks!

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

            vicky457 wrote:

            But I try to pass Form1 into Javascript function , it won't let me do it.

            What code do you use to try that? What do you mean by "won't let me"? What error message do you get?

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