how can I update server side control purely by events triggered by server side timer

Currently I am writing code based on google earth API. Basically server writes a piece of KML info every second,(using AddHandler aTimer.Elapsed, AddressOf OnTimer) then the browser uses XMLHttpRequest to retrieve this KML and display it on the Google Earth plugin.
This part works fine, however when there is no more KML to write on the server, I want to disable some buttons running on the server. Unfortunately I cannot achieve it. If I use update method of UpdatePanel (I put those buttons in the UpdatePanel), it pops up the error of "The Update method is called during or after the page's Render event". Any Suggestion about the problem? I guess since there is no postback from the client at this time, the client cannot be updated?

 
                        
                
 
Private Sub OnTimer(ByVal source As Object, ByVal e As Timers.ElapsedEventArgs) 'make sure the kmlreader has not finished reading the simulation file If kmlreader(cntKmlReader).GetKmlReaderState = System.Xml.ReadState.Closed Then curContext.Response.Write("alert(' Writing Finished')") btnPause.Enabled = False btnResume.Enabled = False btnFast.Enabled = False btnSlow.Enabled = False lblStatus.Text = "Simulation Terminated." UpdatePanel1.Update() 'The Update method is called during or after the page's Render event aTimer.Enabled = False kmlreader(cntKmlReader).emptyKml() Else kmlreader(cntKmlReader).OnTimerReadLoop() End If End Sub Thank you very much!
0
dongsuyangflkl
1/24/2009 6:01:41 PM
asp.net.ajax-discussion 13973 articles. 1 followers. Follow

2 Replies
1261 Views

Similar Articles

[PageSpeed] 42

 The server can't control what happens on the client. It can only provide content (HTML, scripts etc.) when the client asks for it. Therefore I suggest that you use an AJAX client side timer instead. 

You can use a timer in the global HttpApplication (although there are some lifecycle issues wityt that) or in an external process, such as a Windows Service. There's no good way to use in in a Page though, since a Page instance should only live fo the duration of a single request,


-- "Mark As Answer" if my reply helped you --
0
gunteman
1/24/2009 7:52:17 PM
Thank you very much! This does answer my question! But I think I won't use Ajax Client side timer which may put extra overhead to the request traffic. Maybe I will make the server write some default info into the KML file when finishes writing, and thus lets the client to know the status of the server and change the enable attribution of those controls on the client side.Thanks!



But I am new to asp.net, could you explain a little detail about how to put a timer in the global HttpApplication?
Thanks!
0
dongsuyangflkl
1/24/2009 9:11:35 PM
Reply:

Similar Artilces:

Firing both Client side event and server side event for server side button
I am having some difficulties getting this to work.. I have button_click (Asp.net) and ClientClick (Javascript).  Javascript is firing fine.  Server script is not. may be you have return return false in the in the javascript which is why its not firing server side event.You should add javascript evelt like thisbutton1.onclientclick = "functionname" Function should nopt return false. Vikram www.vikramlakhotia.comPlease mark the answer if it helped you...

Can AJAX from the server-side initiate an update of a client-side Update Panel ?
I have a website where multiple users are updating various pages of data. If a user updates a particular section that other people are looking at I'd like to be able to trigger an update in the other peoples' Update Panels. Is this possible?RegardsMatthew You can update a panel from server-side code, by simply use the Update method of the UpdatePanel that you want to update./Fredrik Normén - fredrikn @ twitterMicrosoft MVP, MCSD, MCAD, MCTASPInsidersMy Blog How do I get an event on one user's page to update other users' pages asyncronously? My first thought was to record the events of...

server-side control inside another server-side control
Hi everyone. I have a requirement where I need to create a custom server side control which will contain a series of ASP controls -- no problem there. However, this component also needs to itself be placed inside a server side control, and then placed into the page...so I'll have a custom server-side component inside a custom server-side component. Is that even possible? Everytime I start to think about it I get a headache. Thanks Matt  It's perfectly possible. Just give it a try and you'll see that it works.-- "Mark As Answer" if my reply helped you -- Yup...

server side controls in a non-server side form
I want to use server side controls in a non-server side form.I use server side controls (like dropdownlists) so I can fill them with the right options from the database.My question is, what is the best way to approach this?CAN I use server-side controls in a client side form? If so, how can I get the values contained in the controls when I do a post? (not in a querystring).Here's a sample of my code: <form id="frmAdvancedSearch" method="post" action="advancedSearch.aspx"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <input type="submit" /> </form>...

controls won't update or events fire on server side in AJAX application.
I have an ajax app with VB.NET on the server side and javascript on the client side, which uses callbacks. On the page I have several check boxes, radio buttons, text boxes and slider extenders. The client calls code on the server, but when the server code reads the controls they see the initial values, not the current values.  I tried using "change" events for the controls, but they won't fire on the server side. I also tried putting them all in an update panel triggered on the events of those controls, but it still doesn't work.  Everything works OK on the cli...

Server Side control invoking a Client Side event
I need to figure out how to get a server side control to process the "OnMouseOver" event. Since server side controls do not have the onmouseover event associated with them, how would you make for example, a DropDownList have a "OnMouseOver" event associate with it? The DropDownList must be server side. I guess the idea here is to set client-side events on the server-side control. Any help will be appreciated. You may try something like this: In server side code DDL1.Attributes.Add("onmouseover", "javascript:alert('Hi')") Th...

How can you raise server side event from client side
Let's say I have an event on server side that handles button_click. how can I raise that event from client side using AJAX. You can create a script in a string variable, and register withScriptManager.RegisterStartupScript http://msdn.microsoft.com/en-us/library/bb359558.aspx string script = "alert('ciao!')";ScriptManager.RegisterStartupScript( this, this.GetType(), "Alert", script, true );If this answers your question, please select 'mark as answer' thanks!Andrea DottorMicrosoft MVP - ASP/ASP.NEThttp://blog.dottor.net For buttons you can use JQu...

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in asp.net ( required field, range validator and others)..my question is the required field validator is a server side control. So does that mean that it does a post back?..is it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

ajax
Dear all, I made my own autoComplete extender because the standard one was not suitable for us... I have a problem to returning a property value of my extender that was changed on the client-side. I used the default extender template in order to create it. Does anyone knows how to update a property on client-side and get its value on the postBack? Normally the GetPropertyValue of the ExtenderControlBase should pick the value from client but it returns the default value on null... Please help me... Thank you very much Hi Have you or anybody else managed to find a solution for this...

Calling a client side control event from a server side function
I would like to know how to raise an event on a client side only control from a server side function.   For example, I have Button1 whose onclick is handled at the server. The logic behind the function will do 1 of 2 things, change the text of a label to indicate a problem or navigate to a new page.  I cannot use redirect because i need the new page to appear inside 2 of 3 existing frames.  I can manage this using an anchor on the client.  All I need to do is automatically click the anchor after I post back from the Button1.click event.I tried the following line of c...

making enter key in server side textbox cause a server side button event
hi,  I have a asp control textbox with an asp button next to it ( ie both server side asp controls).  If  I press the enter key when focus is on the textbox - how can I trigger the enter button event to fire off at the server ?  Many thanks? ubique--Regarding this... ubique wrote:...I have a asp control textbox with an asp button next to it ( ie both server side asp controls).If  I press the enter key when focus is on the textbox - how can I trigger the enter button event to fire off at the server ?...I have to ask: why do this?...why not simply have the endus...

How to access Client Side control in server side button click event?
Hi all, I need to access client side control from server side code. For an example <form id="form1" runat="server"> <table> <tr> <td>UserName:</td> <td><input type="text" id="textBoxUserName" /></td> <td><asp:Button ID="buttonShow" runat="server" Text="show" OnClick="buttonShow_Click" /></td> </tr> </table>   </form> I need to access the textBoxUsername in the server side button click event. How to do that? Than...

Updateting Server side variable through javascript or how can i user Javascript variable in server side C# ?
 Hi I am new for web development. I wasted fewdays but I am not able to figureout following problem.1. I have Javascript variable I want to use in Server side C# is it possible ?2. If above is not possible if i declare variable in C#  and is it possible to update through Javascript ?As I am new for web development Please give me sample code for example it will be very easy for me to understand. If  both way possible please explain me both way. Thanks in anticipationHarshad   Yes it is possible to get the value of your javascript variable in C#. here's how:1. In...

Combining a server-side control with a client-side control!
Hi all, I am trying to combine a server-side control with a client-side control. I have created a listbox in both sides, the client-side control's code is: <select size="4" name="lstFruit" id="Select1" ondblclick="lst_dblClick" visible="false"> <option value="Banana">Banana</option> <option value="Apple">Apple</option> <option value="Mango">Mango</option> <option value="Orange">Orange</option> </select> The other one is the server-side control which has this code:   I wanted to add the ondblClick attribute to the se...

Web resources about - how can I update server side control purely by events triggered by server side timer - asp.net.ajax-discussion

Transport triggered architecture - Wikipedia, the free encyclopedia
In computer architecture , a transport triggered architecture ( TTA ) is a kind of CPU design in which programs directly control the internal ...

Managing the Storm How CSO Control Facility Operators Manage Pollution Triggered by Rain Storms
When it rains, most of us don't give a second thought to where all of the storm water goes. The story of what happens when it enters the sewer ...

'No' from one Iraq villager triggered Islamic State mass killings, says witness
When Islamic State militants stormed into a northern Iraqi village and ordered everyone to convert to Islam or die only one person refused. But ...

Police chief's dash for freedom triggered a landslide
Police chief's dash for freedom triggered a landslide

Al-Qaeda leader Ayman al-Zawahiri's message to Yemen chief triggered US embassy terror alert
The Obama administration's decision last week to close nearly two dozen diplomatic missions and issue a worldwide travel alert resulted from ...

Robin Williams suicide triggered by dementia, hallucinations: report
Robin Williams was suffering from a form of dementia that his family believes was a "key factor" leading to his suicide earlier this year, according ...

'Fear' triggered man to shoot Cookson
A Perth man on trial for killing his underworld housemate claims he was forced into having a threesome with the drug dealer during months of ...

Mining triggered Newcastle quake, says US academic
A United States academic claims the 1989 earthquake which devastated Newcastle was triggered by coal mining in the region.

Tofino boat rescue triggered by single flare that almost wasn't seen
Since he pulled 13 survivors out of the water near Tofino, B.C., on Sunday, Ken Brown has thought a lot about what would have happened, if he ...

Lies triggered $12.8M in bonus payments for Nortel execs, fraud trial hears
Three former Nortel executives manipulated financial records to reap millions in bonuses, keeping the now insolvent tech firm's investors and ...

Resources last updated: 12/30/2015 12:01:25 AM