Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > HTML Reset Button Doesn't work after postback with Submit button

Reply
Thread Tools

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

 
 
Chris Lane
Guest
Posts: n/a
 
      11-17-2003
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
 
Reply With Quote
 
 
 
 
Chris Bower
Guest
Posts: n/a
 
      11-17-2003
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" <(E-Mail Removed)> wrote in message
news:027101c3ad3a$24a41f70$(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
Chris Lane
Guest
Posts: n/a
 
      11-17-2003
Thank You.
>-----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" <(E-Mail Removed)> wrote in message
>news:027101c3ad3a$24a41f70$(E-Mail Removed)...
>> 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

>
>
>.
>

 
Reply With Quote
 
Chris Lane
Guest
Posts: n/a
 
      11-17-2003
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" <(E-Mail Removed)> wrote in message
>news:027101c3ad3a$24a41f70$(E-Mail Removed)...
>> 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

>
>
>.
>

 
Reply With Quote
 
Chris Lane
Guest
Posts: n/a
 
      11-17-2003
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" <(E-Mail Removed)> wrote in message
>>news:027101c3ad3a$24a41f70$(E-Mail Removed)...
>>> 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

>>
>>
>>.
>>

>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
STRUTS- <html:submit> does not submit on pressing Enter key Megha Vishwanath Java 2 10-02-2009 12:52 PM
Controls reset after postback, why? =?Utf-8?B?QXJ0?= ASP .Net 3 05-26-2006 01:53 PM
Submit button does not work after applying Critical Upgrades Ray ASP .Net Web Services 0 08-22-2005 02:05 PM
Changing a HTML submit button that requests a Servlet, to an image button? How? James Storey via JavaKB.com Java 7 04-08-2005 06:10 PM
Button vs HTML Submit Button Olivier Matrot ASP .Net Web Controls 3 02-23-2005 07:55 AM



Advertisments