469,608 Members | 2,049 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,608 developers. It's quick & easy.

HTML Reset Button Doesn't work after postback with Submit button

Hi,

I have an HTML RESET button and Web Control Button that
posts back to the server. Problem is the reset button
doesn't work after the postback occurs. Any ideas or
suggestions as to why this happens or how I can work
around this?

Thanks
Nov 18 '05 #1
4 10574
It doesn't work because HTML Reset buttons reset the controls in a form back
to the value they were when the page first loaded. When you post back, the
ASP.NET engine sets the values of the controls again, so the Reset would do
nothing more than change the controls back to what they were when you loaded
the page after the postback.

The only solution to this is to either do it client-side with javascript or
server-side on a postback. Just iterate through all of your controls and set
their properties appropriately.
"Chris Lane" <rc*********@yahoo.com> wrote in message
news:02****************************@phx.gbl...
Hi,

I have an HTML RESET button and Web Control Button that
posts back to the server. Problem is the reset button
doesn't work after the postback occurs. Any ideas or
suggestions as to why this happens or how I can work
around this?

Thanks

Nov 18 '05 #2
Thank You.
-----Original Message-----
It doesn't work because HTML Reset buttons reset the controls in a form backto the value they were when the page first loaded. When you post back, theASP.NET engine sets the values of the controls again, so the Reset would donothing more than change the controls back to what they were when you loadedthe page after the postback.

The only solution to this is to either do it client-side with javascript orserver-side on a postback. Just iterate through all of your controls and settheir properties appropriately.
"Chris Lane" <rc*********@yahoo.com> wrote in message
news:02****************************@phx.gbl...
Hi,

I have an HTML RESET button and Web Control Button that
posts back to the server. Problem is the reset button
doesn't work after the postback occurs. Any ideas or
suggestions as to why this happens or how I can work
around this?

Thanks

.

Nov 18 '05 #3
OK I made the HTML RESET Button an HTML Server Control.
I then added the following code:
Private Sub btnReset_ServerClick(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnReset.ServerClick
txtStoreName.Value = ""
txtCity.Value = ""
txtPostalCode.Value = ""
txtStreet.Value = ""
txtPhone.Value = ""
txtAreaCode.Value = ""
End Sub
I stepped thru this in debug mode and the
btnReset.ServerClick method does not fire.
I will try it with a web control button and see if that
works.
Any suggestions or ideas?
-----Original Message-----
It doesn't work because HTML Reset buttons reset the controls in a form backto the value they were when the page first loaded. When you post back, theASP.NET engine sets the values of the controls again, so the Reset would donothing more than change the controls back to what they were when you loadedthe page after the postback.

The only solution to this is to either do it client-side with javascript orserver-side on a postback. Just iterate through all of your controls and settheir properties appropriately.
"Chris Lane" <rc*********@yahoo.com> wrote in message
news:02****************************@phx.gbl...
Hi,

I have an HTML RESET button and Web Control Button that
posts back to the server. Problem is the reset button
doesn't work after the postback occurs. Any ideas or
suggestions as to why this happens or how I can work
around this?

Thanks

.

Nov 18 '05 #4
Ok I figured out what I did wrong.
I forgot to change the HTML Property Type = reset to
Type = button.
Now the serverside click event occurs for the HTML Server
Control.
Again Thank You for your help.
-----Original Message-----
OK I made the HTML RESET Button an HTML Server Control.
I then added the following code:
Private Sub btnReset_ServerClick(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnReset.ServerClick
txtStoreName.Value = ""
txtCity.Value = ""
txtPostalCode.Value = ""
txtStreet.Value = ""
txtPhone.Value = ""
txtAreaCode.Value = ""
End Sub
I stepped thru this in debug mode and the
btnReset.ServerClick method does not fire.
I will try it with a web control button and see if that
works.
Any suggestions or ideas?
-----Original Message-----
It doesn't work because HTML Reset buttons reset the

controls in a form back
to the value they were when the page first loaded. When

you post back, the
ASP.NET engine sets the values of the controls again, so

the Reset would do
nothing more than change the controls back to what they

were when you loaded
the page after the postback.

The only solution to this is to either do it client-side

with javascript or
server-side on a postback. Just iterate through all of

your controls and set
their properties appropriately.
"Chris Lane" <rc*********@yahoo.com> wrote in message
news:02****************************@phx.gbl...
Hi,

I have an HTML RESET button and Web Control Button that
posts back to the server. Problem is the reset button
doesn't work after the postback occurs. Any ideas or
suggestions as to why this happens or how I can work
around this?

Thanks

.

.

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by William Ryan | last post: by
3 posts views Thread by Frances Del Rio | last post: by
4 posts views Thread by Spence Hackney | last post: by
4 posts views Thread by bbp | last post: by
7 posts views Thread by CharlesA | last post: by
2 posts views Thread by ruthiefy | last post: by
reply views Thread by Bobby Edward | last post: by
7 posts views Thread by ghjk | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.