Stack User
Stack User

Reputation: 1398

Without refreshing page, changing value

I have an ASP.NET page, the menu comes from menu.ascx in masterpage.

Menu includes below items:

  • Request(5)

  • Info

In menu.ascx.cs, I calculate 5. It comes from a SQL query like

Select Count(*) From Request Where Id = 1; //returns 5

For instance; in other page, I edit any record and the result of query will be 6. But without refreshing page it does not change and still seems 5.

Are there any way to do it without refreshing page except for Ajax solutions? When I edited any record can I refresh all page?

Upvotes: 0

Views: 1113

Answers (4)

VRK
VRK

Reputation: 400

I would say AJAX is a well known option here to update partial page.

Upvotes: 1

code4life
code4life

Reputation: 15794

You can also look at the XmlHttpRequest object that is available in JavaScript. You can embed the script in your web page via the usual methods.

An example can be found here.

Upvotes: 1

Kris van der Mast
Kris van der Mast

Reputation: 16613

There is no way to get that updated in the browser without resorting to either one of these options:

  • full page refresh (postback)
  • ajax (either via the provided server controls like UpdatePanel or via plain self written javascript ajax calls, ps: think jQuery to smoothen this process)

A newer approach would be to make use of Websockets where you can push data from the server to the client. Microsoft has created a cool library, with various fallback scenarios, in SignalR.

Upvotes: 2

saluce
saluce

Reputation: 13360

Wrap the HTML you want refreshed in an UpdatePanel, which will allow partial page updates. It is an AJAX-based solution, but there is no way to perform a partial page update with information from the server without using AJAX.

Upvotes: 2

Related Questions