Calling JavaScript function after ASP button postback arcgis JavaScript API

675
3
04-07-2014 02:08 AM
ChristianDebono
New Contributor II
Basically I have an event on an ASP.Net button in an Update Panel which retrieves x and y coordinates from a database. Then I am populating a hidden field with these coordinates and I have a JavaScript function which displays points according to the coordinates retrieved from the database and stored in the hidden field. My problem is how do I call this function after the hidden field is populated, with out refreshing the page.
3 Replies
JonathanUihlein
Esri Regular Contributor
Basically I have an event on an ASP.Net button in an Update Panel which retrieves x and y coordinates from a database. Then I am populating a hidden field with these coordinates and I have a JavaScript function which displays points according to the coordinates retrieved from the database and stored in the hidden field. My problem is how do I call this function after the hidden field is populated, with out refreshing the page.


You should be able to set up a callback function for when you receive the x,y data from your database.
In this callback, trigger the display function.

Personally, I would use dojo/Deferred. http://dojotoolkit.org/documentation/tutorials/1.9/deferreds/
0 Kudos
ChristianDebono
New Contributor II
Thanks jonathan uihlein for your reply. I have solved this problem by calling the JavaScript function from the click event of the submit button in asp.net

ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "drawPoints();", true);
0 Kudos
JonathanUihlein
Esri Regular Contributor
Great! I've not done much with ASP.net personally but this solution looks best for your app.
As long as getDraw() waits for the data from the database, you should have no issues.
0 Kudos