473,411 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

How to clear form after postback

Hi,

I have an asp.net page with a form. When the submit button is clicked it
sends an email.

When the page reloads the form fields are still filled with the info that
just got submitted.

I tried
<%@ Page EnableViewState="false" %>
but it doesn't clear the form.

I also tried EnableViewState="false" in each form element and that doesn't
work either.

How can I disable the postback information?

Thanks!!!
Nov 18 '05 #1
5 12980

"Dave" <st****@games.com> wrote in message news:uj****************@TK2MSFTNGP12.phx.gbl...
Hi,

I have an asp.net page with a form. When the submit button is clicked it
sends an email.

When the page reloads the form fields are still filled with the info that
just got submitted.

I tried
<%@ Page EnableViewState="false" %>
but it doesn't clear the form.

I also tried EnableViewState="false" in each form element and that doesn't
work either.

How can I disable the postback information?

Thanks!!!


This is standard Postback behavior that is very useful when you have server-side validators.

You have two options:
1) when the email is successfully sent, clear all fields
2) do a redirect (to the same url), after sending.

The disadvantage of 1 is that when the user refreshes the page,
the email might get sent again (this empty page was the result of a
form submission, refresh submits the original form again ...).
You don't have that problem with 2.

Hans Kesting
Nov 18 '05 #2
One question. If you use method 2, will this not start a new session each
time. ?, if so this could eat up a lot of memory if someone is sitting there
sending loads of emails

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

"Dave" <st****@games.com> wrote in message news:uj****************@TK2MSFTNGP12.phx.gbl...
Hi,

I have an asp.net page with a form. When the submit button is clicked it sends an email.

When the page reloads the form fields are still filled with the info that just got submitted.

I tried
<%@ Page EnableViewState="false" %>
but it doesn't clear the form.

I also tried EnableViewState="false" in each form element and that doesn't work either.

How can I disable the postback information?

Thanks!!!


This is standard Postback behavior that is very useful when you have

server-side validators.
You have two options:
1) when the email is successfully sent, clear all fields
2) do a redirect (to the same url), after sending.

The disadvantage of 1 is that when the user refreshes the page,
the email might get sent again (this empty page was the result of a
form submission, refresh submits the original form again ...).
You don't have that problem with 2.

Hans Kesting

Nov 18 '05 #3

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:Oo*************@TK2MSFTNGP11.phx.gbl...
One question. If you use method 2, will this not start a new session each
time. ?, if so this could eat up a lot of memory if someone is sitting there
sending loads of emails

--


No, a redirect leaves you in the same session.

Some reasons to get a new session:
*) When you first close all browser windows (so that the session-cookie
gets destroyed) and then open a new one.
*) When you use a browser of a different brand (or maybe a new instance
of your current browser, "new window" usually is NOT enough)
*) When you don't access the site for (default) 20 minutes.
*) When the server code specifies that the session should be destroyed
(maybe after a "logout")

Hans Kesting
Nov 18 '05 #4
Thanks

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:uE*************@tk2msftngp13.phx.gbl...

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message news:Oo*************@TK2MSFTNGP11.phx.gbl...
One question. If you use method 2, will this not start a new session each time. ?, if so this could eat up a lot of memory if someone is sitting there sending loads of emails

--


No, a redirect leaves you in the same session.

Some reasons to get a new session:
*) When you first close all browser windows (so that the session-cookie
gets destroyed) and then open a new one.
*) When you use a browser of a different brand (or maybe a new instance
of your current browser, "new window" usually is NOT enough)
*) When you don't access the site for (default) 20 minutes.
*) When the server code specifies that the session should be destroyed
(maybe after a "logout")

Hans Kesting

Nov 18 '05 #5
Thanks Hans,

That seems to work.

I put redirect after the email send line.

The first time I submitted the page it didn't load the page though. The
page came up with a link. Click the link and it loads the page.

Subsequent submits came up correctly.

Is that right?

BTW, this is off topic, but how can I submit a page using an image and not a
button in asp.net?

Thanks!!!
Dave
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Raterus | last post by:
Howdy, Simple question, but I can't figure out how to do it. I have a a page which is called initially with a querystring. After I get the querystring values, I don't need the querystring to...
3
by: jw56578 | last post by:
When a page does a post back and there is data in a textbox, that textbox will get automatically repopulated with that data due to the posting of the form. Disabling viewstate has no affected on...
2
by: John | last post by:
Hi all, After one of my user controls does either a server.transfer or response.redirect, the action method in a my resulting html form is being set and any request variables changed at the...
2
by: tshad | last post by:
Is there a way to tell a screen on Postback to clear all the objects (or put them back to their defaults on Postback)? At the moment, I am just going through and setting them manually before...
0
by: Cleako | last post by:
Here is my dilema. I have a validation summary that I use soley for my Required Field Validators. I have it setup to run from a Page.Validate call in the code-behind, this is because I need to...
3
by: Jeff User | last post by:
Greeting I built asp.net (V1.1) page. I want to use this button to reset SelectedIndex=0 on several drop down lists. However, I do not want to post back to server. The point is to avoid the...
12
by: Mark Rae | last post by:
Hi, See the previous thread Request.Form abuse in this newsgroup... I'm looking for a simple and efficient way to prevent people hijacking the <formtags on my websites and using them to send...
0
by: ThunderMusic | last post by:
Hi, I have a page where I have an input type=file control and many other controls... the thing is, when I cause a postback by any control on the page, if a file is selected in the input...
2
by: =?Utf-8?B?Y2FzaGRlc2ttYWM=?= | last post by:
Hi, Is it possible to clear the recent history so that a link with the href "javascript:window.history.back()" doesn't record any postbacks? For example, if I the user makes a few selections...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.