Clearing the data....

P

Paul King

I have created a form on the web that allows us to update a table on our SQL
server using the INSERT function.

The way the page is constructed is that the results panel refreshes with the
new data after a post has been issued. This is fine and dandy, but if we
were to refresh the browser, this would duplicate another record with the
same details.

I would there like to either:

A) Clear the input from the screen after a POST has been issued or,
B) Clear the DataSet data so that this will not duplicate the information if
a refresh was issued.

Please can you help

Thanks
Paul
 
K

Kevin Spencer

Simplest solution: After the INSERT is performed, do a Response.Redirect
back to the same page.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
P

Paul King

Kevin

Thanks for the information - the only problem is that you can Invoke the
Response.Redirect or Server.Transfer to clear the entry of the form.

However if you hit the refresh button on a blank form this will duplicate
another entry into the SQL from the DataSet. I need to somehow also clear
the DataSet.

Regards
Paul.
 
K

Kevin Spencer

I didn't say anything about Server.Transfer. Response.Redirect tells the
browser to request a new URL. Refreshing the page redirected to does just
that: it refreshes the page that the Redirect linked to.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
P

Paul King

No problems Kevin, I will use the Response.Redirect.

I just done a web search on Response.Redirect and it recommended to use
Server.Transfer as this was less intensive on IIS.

Regards
Paul.
 
K

Kevin Spencer

Response.Redirect sends a Response to the Client browser, which tells it to
request another page. Yes, this does mean that the server will receive 2
requests from the client, whereas Server.Transfer transfers control to
another class without redirecting. However, there are reasons for both
methods to exist. Only Response.Redirect will ensure that a Refresh from the
browser will not cause the last PostBack to re-occur. It's not like the 2
are interchangeable. When you need to hammer nails, use a hammer, not a
screwdriver.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
P

Paul King

I like your analogy.

I guess when ASP 2.0 is officially released this might include better, more
efficient classes??

Regards
Paul.
 
K

Kevin Spencer

ASP 2.0 will include new features and classes. However, Response.Redirect
and Server.Transfer are not likely to be affected.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top