Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Real Time" synchronous update

Status
Not open for further replies.

jon24422531

Technical User
Jan 27, 2004
295
0
0
GB
We have an internal web application for fault reporting and all the info is stored in a SQL database, and with much help from Tek-Tips over the last 18 months, has been a great success.

So a user looks up a fault report and it is displayed on a web page with a textarea for adding to the report etc. When they then press the update button a SQL update statement is passed, an Email is triggered (by the SQL Server) and they are given an "Update" page that says the update has succeeded.

What I would like is for the previous page to reload WITH the update, but I am unsure how to do this.
Will I just have to recreate ALL the code on the "Update" page or is there a method of retaining the original SQL query and HTML formatting?

Hope that makes sense.

Jonathan
 
Is the select statement in the same page with the update statement? Where do users go after the update?
 
You don't have to do anything. When user go back to display page, this page refreshes with the new updated reports.
 
Ah, I think I know what you want. Instead of taking the user to the update page, just take them back to the display page. If you want to inform user that the record has been updated, you can display a message on the page or popup a window to say so.
 
Kendel

Thanks for your response. In answer to the first question, no the select statement collects information about the 'fault' and has a textarea with a button. This goes to another page with the Update statement that displays a message to say that the update has been sent to the server. What I want to know is whether it is possible for either the user to be returned to the "textarea" page with the new information added/changed, or for the select statement to be run dynamically and the "textarea" page just refreshed?

Jonathan
 
The page that displays the message is popup window? If it is a popup window, you will need some javascript to refresh parent window. If it is not, like I said, after user click update button, instead of going to the page to display the message, go back to the "textarea" page. This "textarea" page will display the latest updated records.
 
But that is my point, can pressing a button run some ASP code without moving to another page? I understood that ASP only runs on page load, not on an ad-hoc basis.

At the moment the user is passed to another page with the variable of the fault report to be updated.

Jonathan
 
you're getting into AJAX here. In order to run ASP without refreshing the page, collect the values into javascript, pass them to an asp page using an xmlhttp request objects via querystring.

The asp page can do what it needs to do and generate xml code with the results.

These results are then read by your javascript and your page is re-populated with the values.

It may sound complex, but it's very easy to implement - let me know if you need a code sample and I'll send it over.

The other way to do it (without refreshing the page) is to place an invisible iframe on your page and post your form to it (target="myiFrame"). The page won't reload, but the data will be written into the database.
 
There you go.

Another solution is to post the form back using the form action:

On page1.asp
<form name="form1" method="post" action="page1.asp">

Then you check to see if the form is posted back, this piece of code will only execute when the form is posted back.
Code:
<% 
If Request("postback")="true" then
   'execute update statement here
   'then popup an alert saying that the record has been updated
   Response.write("<script>alert('Record updated')</script>");
End if
%>
 
several ways, as mentioned by the others, alot falls into ajax as kendel mentioned, you can also look into how to make ASP chat, using JS and XMLHTTP and write the response.

pass the formatting/SQL data in the same form for posting the response and re-display plus their submission..

all depends on what you want to sink into it, and what desired results you want.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never inside the 'loop' " - DreX 2005
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top