Running javascript from server side.
-
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 ThanksJimBob SquarePants ******************************************************************* "He took everything personally, including our royalties!" David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager *******************************************************************
-
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 ThanksJimBob SquarePants ******************************************************************* "He took everything personally, including our royalties!" David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager *******************************************************************
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
-
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
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 *******************************************************************
-
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 *******************************************************************
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
-
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
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 JamesJimBob SquarePants ******************************************************************* "He took everything personally, including our royalties!" David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager *******************************************************************