aspx refresh page problem

Soldato
Joined
18 Oct 2002
Posts
15,861
Location
NW London
Hi,

I have created a simple page here:

http://aspspider.net/sunama/

Now, when I press a button, the entire page automatically refreshes.

Question:
Is there any way I can prevent the page from refreshing?

Eventually what will happen is that a user will type in some information in the lower text box, press the "send message" button. At this point the text input, will appear in the top text box, and disappear from the bottom text box.

I would like all of the above to happen without the page refreshing.

Is there any way I can achieve this?


Thanks
 
You will want ajax for this kind of interaction, or you could possibly use frames or iframes to refresh the content.
 
You will want ajax for this kind of interaction, or you could possibly use frames or iframes to refresh the content.

If I use frames, would this mean that I place the entire application window (ie. grey area only), into a single frame. Would this do it?
 
Made a similar application with classic asp years ago and just used a standard frameset, so its definately possible without using ajax.
 
Right gents. Thanks for the suggestions so far.

I have managed to prevent the auto reloading when pressing buttons.

However, also have a timer which much run in the back ground and tick every x MS. Everytime this timer ticks, this also has the effect of reloading the page. When this happens, the page Page_Load sub is activated and all manner of "stuff" happens.

What I want to do is prevent the page itself from reloading (just like a system app). The web app which I am creating is actually a system application and I am basically porting it over.

So, is there anyway that I can prevent the timer from reloading the page?
 
Well, can't you just make the timer reload the part of the page?

Assuming its an iframe/frame whatever or even ajax/ajax extension.
 
I'm using Ajax updatepanel.

I actually don't want the timer to reload the page at all, but it is doing it anyway. Is there a way to stop it from reloading the full page or any part of it?
 
Actually the timer is doing other stuff.

In particular it is checking an arrayList and if the arrayList has any strings in it, it is responsible for loading these into the top textBox (on the form).

The only way around this would be to use a thread, but to use a thread to update controls seems difficult. I've tried using a delegate (which is what I use for updating controls with threads, in system apps), but this technique is not working in the web app.
 
I'm not familiar with .net forms, but this only needs to be returned to the ajax control from the timer. Does the timer not support this kind of action?
 
There doesnt appear to be a way to bind or limit the extent of the timer's scope.

Whenever it fires, it automatically reloads the entire page. The effect of this is that all the App Code is re-initialised, everytime the page is reloaded. This effectively resets all the variables in the all the classes contained within the App Code.

Its the equivalent of creating a system app, which closes and then re-starts the application, every time a timer ticks.
 
I dislike asp .net forms :D

Not sure that your timer is firing correctly.

Have to go to bed now anyway!
 
Last edited:
I don't wish to sound nasty, but does the OP have any experience in ASP.NET Webforms? The issues and behaviour you're describing are pretty basic and trivial, and you seem surprised that an asp:Button control is "refreshing the page" - well it isn't, it's doing a Postback and that's standard behaviour!

Take a look at http://www.asp.net/ for some tutorials that should cover the basics. Save yourself lots of pain in the long run by learning how to do it properly now!
 
I am having a read through the life-cycle of the page and shall be spending time to reading up on ASP (I hate web programming with a passion).

My problem is that I am not an asp programmer and don't wish to be. I merely wish to port the vb.net system application (which is working beautifully), to the web, for testing purposes. That's all. If I have to McGuyver a dirty method to do this, then so be it. I don't want to spend weeks/months learning ASP when I really need to be spending my time developing my AICore server.

The web application is important though, which is why I am putting the time into getting it (almost) working correctly.

Anyway, I've spend the last 24 hours attempting to sort the problem with the timer.

I've posted my efforts up here:
http://aspspider.net/sunama/webchat.aspx

Bear in mind this is very much a test page and I am changing/updating/experimenting with this as I am going along.

I have left the AICore server running in the background, so you should be able to connect/disconnect (using the 2 buttons).

The problem is that due to the timer updating every 1s, it is impossible to type anything into the text box, because every time the timer updates the page, any text you may have typed out, is gone.

The IsPostBack method is doing absolutely nothing, so I have used a "dirty" method inorder to prevent all the variables being re-initialised.

The main problem here is that the timer is updating all the controls of the page on every tick. The variables are all behaving correctly, but the controls are not.

Is there a way for me to select the controls which are excluded from the timer tick update?

Thanks.
 
Had a look at the page and it seems to be working fine for me in Chrome - assuming you sorted it?

Assuming you're still having problems, have you tried moving the bottom text box outside of the UpdatePanel? That should stop it being updated.

One thing I don't understand is why you want a timer on a 1 second tick. Would it be better if there's only an asynch postback when the user presses a button?

If you don't need the timer, I'd set triggers for the update panel so that the button triggers the postback and runs the code referenced in the EventName attribute. Something like:

Code:
<asp:UpdatePanel id="YourUpdatePanelIDHere" runat="server" UpdateMode="conditional">
     <triggers>
          <asp:AsyncPostBackTrigger ControlID="SendMessageButton0" EventName="ButtonClick" />
     </triggers>
</asp:UpdatePanel>
 
Back
Top Bottom