Question on DotSpatial.Examples.DemoWeb

Apr 13, 2012 at 10:38 AM

I need to create a web page similar to the one in DemoWeb where the map view is refreshed periodically - say, every 30 seconds. I know how to do the periodical function call in JavaScript. Basically I would have to invoke periodically the stuff done by the refresh button in default.aspx (an ASP.Net ImageButton) which, when clicked, refreshes the map view.

How does that button work? I could not see any event handler for this button. In the html view of default.aspx the ImageButton is defined only with style attributes, and in the Properties dialog no event is wired. For me as developer, it looks as though that button was just an inert element in the web page. Yet when  I load the page in a web browser, that button works OK; it is somehow wired to an event handler, but how and which one?

Developer
Apr 13, 2012 at 12:21 PM
Edited Apr 13, 2012 at 12:38 PM

The button simply do a PostBack to the server (each asp button do this, is different from html button).

There is a timer control that works with AJAX in asp.net controls:

http://msdn.microsoft.com/it-it/library/bb398865.aspx

 

You can read also this:

http://www.codeproject.com/Articles/12293/Auto-postback-in-ASP-NET

 

When a page is loaded "Page_load" is called by the server and you can know if the page is post back or not. If not means that the page is called for the first time, else your timer is firing.

 

The code may be something like:

 

protected void Page_Load(object sender, EventArgs e)
{

            if (!IsPostBack)
            {
                // Map Create
            }
            else
            {
                 //Map Refresh
            }

}

Apr 13, 2012 at 1:25 PM

Thank you! This is exactly what I was looking for.