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. Running javascript from server side.

Running javascript from server side.

Scheduled Pinned Locked Moved ASP.NET
helpdatabasequestionjavascriptcom
5 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.
  • J Offline
    J Offline
    JimBob SquarePants
    wrote on last edited by
    #1

    Hi there, I'm currently trying to fix a bug in a site that uses a gridview to load info from a database via a few dataviews into several tabs in a tab control. Part of this information is the latitude and longitude which is used to display a map on virtual earth. I am having a problem in that the javascript GetMap() is called by adding an onload command to a body I have nested in the fourth tab. This means that the javascript is only getting called once as I'm using an update panel to remove full postback. I'm calling the javascript from the dataview databinding sub on the server side to prevent the map from being loaded too early without the necessarry information. How can I call the javascript eveytime the index is changed on my gridview?? You can see the problem on http://www.ozfarmguide.com/Farms.aspx[^] Many Thanks

    JimBob SquarePants ******************************************************************* "He took everything personally, including our royalties!" David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager *******************************************************************

    L 1 Reply Last reply
    0
    • J JimBob SquarePants

      Hi there, I'm currently trying to fix a bug in a site that uses a gridview to load info from a database via a few dataviews into several tabs in a tab control. Part of this information is the latitude and longitude which is used to display a map on virtual earth. I am having a problem in that the javascript GetMap() is called by adding an onload command to a body I have nested in the fourth tab. This means that the javascript is only getting called once as I'm using an update panel to remove full postback. I'm calling the javascript from the dataview databinding sub on the server side to prevent the map from being loaded too early without the necessarry information. How can I call the javascript eveytime the index is changed on my gridview?? You can see the problem on http://www.ozfarmguide.com/Farms.aspx[^] Many Thanks

      JimBob SquarePants ******************************************************************* "He took everything personally, including our royalties!" David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager *******************************************************************

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      JimBob SquarePants wrote:

      I'm calling the javascript from the dataview databinding sub on the server side

      No you are not. Server side code cannot call/execute client side code.

      JimBob SquarePants wrote:

      How can I call the javascript eveytime the index is changed on my gridview??

      As I stated above you can't. What one can do is take advantage of whatever client side mechanism they are using, like body.onload event, to execute javascript code. In your case since you are using an Ajax call (update panel) then you need to use whatever mechanism it supplies to execute client code upon return of the request to the browser.

      led mike

      J 1 Reply Last reply
      0
      • L led mike

        JimBob SquarePants wrote:

        I'm calling the javascript from the dataview databinding sub on the server side

        No you are not. Server side code cannot call/execute client side code.

        JimBob SquarePants wrote:

        How can I call the javascript eveytime the index is changed on my gridview??

        As I stated above you can't. What one can do is take advantage of whatever client side mechanism they are using, like body.onload event, to execute javascript code. In your case since you are using an Ajax call (update panel) then you need to use whatever mechanism it supplies to execute client code upon return of the request to the browser.

        led mike

        J Offline
        J Offline
        JimBob SquarePants
        wrote on last edited by
        #3

        Yeah sorry, call was probably not the best choice of words. I tried adding OnLoad="GetMap()" to the markup on my UpdatePanel but I returned this compilation error: 'GetMap' is not a member of 'ASP.farms_aspx'The client side attributes are not available in the code behind unlike the body. Javascript is a great unknown to me. I had real trouble getting the map to show properly in the first place. What's your advice?

        JimBob SquarePants ******************************************************************* "He took everything personally, including our royalties!" David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager *******************************************************************

        L 1 Reply Last reply
        0
        • J JimBob SquarePants

          Yeah sorry, call was probably not the best choice of words. I tried adding OnLoad="GetMap()" to the markup on my UpdatePanel but I returned this compilation error: 'GetMap' is not a member of 'ASP.farms_aspx'The client side attributes are not available in the code behind unlike the body. Javascript is a great unknown to me. I had real trouble getting the map to show properly in the first place. What's your advice?

          JimBob SquarePants ******************************************************************* "He took everything personally, including our royalties!" David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager *******************************************************************

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          JimBob SquarePants wrote:

          Javascript is a great unknown to me.

          JimBob SquarePants wrote:

          What's your advice?

          My general advice is not to work with technology that is unknown to you without first learning it. As to your current problem, I have never worked with the update panel but I imagine there must be a client side mechanism to leverage upon return to the browser. I would also imagine there is some small amount of example code in the MSDN documentation for the update panel control. I would certainly start by looking there. If that is not enough I would goolge for something like: ASP.NET UpdatePanel tutorial

          led mike

          J 1 Reply Last reply
          0
          • L led mike

            JimBob SquarePants wrote:

            Javascript is a great unknown to me.

            JimBob SquarePants wrote:

            What's your advice?

            My general advice is not to work with technology that is unknown to you without first learning it. As to your current problem, I have never worked with the update panel but I imagine there must be a client side mechanism to leverage upon return to the browser. I would also imagine there is some small amount of example code in the MSDN documentation for the update panel control. I would certainly start by looking there. If that is not enough I would goolge for something like: ASP.NET UpdatePanel tutorial

            led mike

            J Offline
            J Offline
            JimBob SquarePants
            wrote on last edited by
            #5

            Thanks for the pointer. Sometimes the problem with Google is knowing what to look for. It turns out I had to put this command into my GetMap() Function: Sys.WebForms.PageRequestManager.getInstance().add_endRequest(GetMap); I understand the principle but not the science itself. Looks like I have a lot of swotting up to do. :sigh: Thanks Again James

            JimBob SquarePants ******************************************************************* "He took everything personally, including our royalties!" David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager *******************************************************************

            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