Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
assume i got 2 pages opened: "add.aspx" and "view.aspx"

add.aspx
- user add new record into sql

view.aspx
- show records from sql


currently im using update panel and timer at view.aspx, so this page will connect to mysql and update the gridview every 10 seconds. and yes, this is a very bad idea.

is there anyway that i can improve this features? i want the view.aspx is refresh ONLY when there is new record added from add.aspx.

I just need an idea/logic how this can be done.
Posted

You are right, this is a real problem. But this is not a simple problem, because Web is primarily based on client-server model, which means pull technology.

Please see my past answers for some background and ideas: Application 'dashboard' for website accounts[^].

Anyway, if you decide not to fight for server push solution and opt for traditional database polling, my other past answer can give you some idea how to suffer less from such problems: Polling Database with Timer[^].

—SA
 
Share this answer
 
Why not create an int in serverside Application?
Lets say Application["UpdateID"] as an int.

When you insert or update into database you can increment it with add.aspx.
In view.aspx you can get data from db when Application["UpdateID"] has changed.
 
Share this answer
 
Comments
melvintcs 7-Feb-14 3:49am    
sorry, what do u meant by "serverside application"? how is view.aspx and "serverside application" communicate?
Per Söderlund 7-Feb-14 4:07am    
In codebehind you can create server application variables.You can get/set it in any codebehind methods.

Check it out here.
http://msdn.microsoft.com/en-us/library/94xkskdf.aspx
melvintcs 7-Feb-14 4:01am    
let me guess. 1.create a session["UpdateID"]; 2.Increase by 1 after add; 3.view.aspx use timer read the session["UpdateID"], if current value is not same with previous value, then only connect to db?
Per Söderlund 7-Feb-14 4:09am    
almost, use Application["UpdateID"] instead of Session["UpdateID"].
with application you can have more browsers connected and updated when others have inserted.
melvintcs 7-Feb-14 4:30am    
thank you for the suggestion. but by reading the value everything 10sec will kill my server or not? imagine if there is 10000 users is on the view.aspx page.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900