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. ScriptManager.RegisterClientScriptBlock pratices

ScriptManager.RegisterClientScriptBlock pratices

Scheduled Pinned Locked Moved ASP.NET
csharpjavascripthelp
6 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.
  • B Offline
    B Offline
    brunoseixas
    wrote on last edited by
    #1

    Hello, I have a Javascript function that needs to be thrown several times in the code-behind(C#) for user navigation. I wanna know if calling the function by the method ScriptManager.RegisterClientScriptBlock is a good practice to resolve this issue. Thanks.

    T N 2 Replies Last reply
    0
    • B brunoseixas

      Hello, I have a Javascript function that needs to be thrown several times in the code-behind(C#) for user navigation. I wanna know if calling the function by the method ScriptManager.RegisterClientScriptBlock is a good practice to resolve this issue. Thanks.

      T Offline
      T Offline
      T M Gray
      wrote on last edited by
      #2

      What kind of method? Does it matter to you when it gets processed during page load? Is there a reason you aren't creating one function that makes all the necessary calls and registering that?

      1 Reply Last reply
      0
      • B brunoseixas

        Hello, I have a Javascript function that needs to be thrown several times in the code-behind(C#) for user navigation. I wanna know if calling the function by the method ScriptManager.RegisterClientScriptBlock is a good practice to resolve this issue. Thanks.

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        brunoseixas wrote:

        a Javascript function that needs to be thrown several times in the code-behind(C#)

        You can't call a JavaScript function from code-behind. You can however write the JavaScript to the output stream. The best way would be to execute the script from the client-side load event such as

        or with JQuery

        $(document).ready( function() { MyFunction(); });


        I know the language. I've read a book. - _Madmatt

        B 1 Reply Last reply
        0
        • N Not Active

          brunoseixas wrote:

          a Javascript function that needs to be thrown several times in the code-behind(C#)

          You can't call a JavaScript function from code-behind. You can however write the JavaScript to the output stream. The best way would be to execute the script from the client-side load event such as

          or with JQuery

          $(document).ready( function() { MyFunction(); });


          I know the language. I've read a book. - _Madmatt

          B Offline
          B Offline
          brunoseixas
          wrote on last edited by
          #4

          Yes, there is a reason. This page uses a free javascript code called niceforms (http://www.emblematiq.com/lab/niceforms/), it has several bugs and needs to be recharged several times. And the problem is that it does not reload correctly if called at events such as onLoad or EndRequest in html (I do not know why). So, I created a static method in BasePage application that contains a method that performs this function across the ScriptManager. The solution I found was this, and I'm just calling it in Page_Load when is postback. Thank you.

          N 1 Reply Last reply
          0
          • B brunoseixas

            Yes, there is a reason. This page uses a free javascript code called niceforms (http://www.emblematiq.com/lab/niceforms/), it has several bugs and needs to be recharged several times. And the problem is that it does not reload correctly if called at events such as onLoad or EndRequest in html (I do not know why). So, I created a static method in BasePage application that contains a method that performs this function across the ScriptManager. The solution I found was this, and I'm just calling it in Page_Load when is postback. Thank you.

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            brunoseixas wrote:

            The solution I found was this...

            No the solution is to use code that isn't buggy and functions appropriately.


            I know the language. I've read a book. - _Madmatt

            B 1 Reply Last reply
            0
            • N Not Active

              brunoseixas wrote:

              The solution I found was this...

              No the solution is to use code that isn't buggy and functions appropriately.


              I know the language. I've read a book. - _Madmatt

              B Offline
              B Offline
              brunoseixas
              wrote on last edited by
              #6

              Yes, of course. Tell that to the dummies of the commercial area. Haaaa :laugh:

              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