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. Asp.Net Javascript-Ajax Coding Style Approach

Asp.Net Javascript-Ajax Coding Style Approach

Scheduled Pinned Locked Moved ASP.NET
javascriptquestioncsharpasp-nettools
6 Posts 2 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.
  • X Offline
    X Offline
    xenonysf
    wrote on last edited by
    #1

    Hi folks! I am new here and i search for my question and find nothing here..:rose: Now i am developing a web application which has to many custom javascript blocks and it includes ms-ajax. Sometimes js codes are written into an external .js file, sometimes they are written into aspx file, some times they are registered from code-behind. Think about how it is getting messy. This might also lead to script conflicts as you might guess. :omg: So what i want to learn is; is there a BEST way for this coding style (arranging js scripts in an very effective way in terms of programmer view and application convenience)?:confused:

    N 1 Reply Last reply
    0
    • X xenonysf

      Hi folks! I am new here and i search for my question and find nothing here..:rose: Now i am developing a web application which has to many custom javascript blocks and it includes ms-ajax. Sometimes js codes are written into an external .js file, sometimes they are written into aspx file, some times they are registered from code-behind. Think about how it is getting messy. This might also lead to script conflicts as you might guess. :omg: So what i want to learn is; is there a BEST way for this coding style (arranging js scripts in an very effective way in terms of programmer view and application convenience)?:confused:

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      xenonysf wrote:

      o what i want to learn is; is there a BEST way for this coding style (arranging js scripts in an very effective way in terms of programmer view and application convenience)?

      There is no rules available on this. I always prefer to write them in a js file. Because it seperates javascript block from the ASPX, and I felt it's easy too.


      My Website | Ask smart questions

      X 1 Reply Last reply
      0
      • N N a v a n e e t h

        xenonysf wrote:

        o what i want to learn is; is there a BEST way for this coding style (arranging js scripts in an very effective way in terms of programmer view and application convenience)?

        There is no rules available on this. I always prefer to write them in a js file. Because it seperates javascript block from the ASPX, and I felt it's easy too.


        My Website | Ask smart questions

        X Offline
        X Offline
        xenonysf
        wrote on last edited by
        #3

        Don't you ever need creating dynamic js code? I think there must be an approach to put script blocks to places that are most suitable. I am just looking for an advice :)

        N 1 Reply Last reply
        0
        • X xenonysf

          Don't you ever need creating dynamic js code? I think there must be an approach to put script blocks to places that are most suitable. I am just looking for an advice :)

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          xenonysf wrote:

          Don't you ever need creating dynamic js code?

          What do you mean by dynamic JS code ?

          xenonysf wrote:

          I think there must be an approach to put script blocks to places that are most suitable

          This depends on the programmer. Putting javascript in js file or putting it in ASPX page won't make any performance difference. I used to do this depends on the requirement. If the page contains big javascript block, I prefer to keep them in external JS file. If it is in a custom server control I prefer to use web resources concept by embedding the javascript files. Hope this helps


          My Website | Ask smart questions

          X 1 Reply Last reply
          0
          • N N a v a n e e t h

            xenonysf wrote:

            Don't you ever need creating dynamic js code?

            What do you mean by dynamic JS code ?

            xenonysf wrote:

            I think there must be an approach to put script blocks to places that are most suitable

            This depends on the programmer. Putting javascript in js file or putting it in ASPX page won't make any performance difference. I used to do this depends on the requirement. If the page contains big javascript block, I prefer to keep them in external JS file. If it is in a custom server control I prefer to use web resources concept by embedding the javascript files. Hope this helps


            My Website | Ask smart questions

            X Offline
            X Offline
            xenonysf
            wrote on last edited by
            #5

            I mean creating a js code by code-behind. like string script = "jscodecode" + var +"codeceode"; ... ok I got what you mean i think. Thanks

            N 1 Reply Last reply
            0
            • X xenonysf

              I mean creating a js code by code-behind. like string script = "jscodecode" + var +"codeceode"; ... ok I got what you mean i think. Thanks

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              xenonysf wrote:

              I mean creating a js code by code-behind.

              This is not a good method until you rally need it. It will be tough to maintain. If you are doing this to get some values from server, you can directly use them in javascript by putting it into a server executable block.


              My Website | Ask smart questions

              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