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

Discussion in 'ASP .Net' started by Chris Lane, Nov 17, 2003.

  1. Chris Lane

    Chris Lane Guest

    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
     
    Chris Lane, Nov 17, 2003
    #1
    1. Advertising

  2. Chris Lane

    Chris Bower Guest

    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" <> wrote in message
    news:027101c3ad3a$24a41f70$...
    > 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
     
    Chris Bower, Nov 17, 2003
    #2
    1. Advertising

  3. Chris Lane

    Chris Lane Guest

    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" <> wrote in message
    >news:027101c3ad3a$24a41f70$...
    >> 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

    >
    >
    >.
    >
     
    Chris Lane, Nov 17, 2003
    #3
  4. Chris Lane

    Chris Lane Guest

    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" <> wrote in message
    >news:027101c3ad3a$24a41f70$...
    >> 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

    >
    >
    >.
    >
     
    Chris Lane, Nov 17, 2003
    #4
  5. Chris Lane

    Chris Lane Guest

    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" <> wrote in message
    >>news:027101c3ad3a$24a41f70$...
    >>> 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

    >>
    >>
    >>.
    >>

    >.
    >
     
    Chris Lane, Nov 17, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Klemt
    Replies:
    0
    Views:
    391
    Andreas Klemt
    Jul 8, 2003
  2. PC Leung
    Replies:
    1
    Views:
    445
    Murray
    Jul 9, 2004
  3. =?Utf-8?B?QXJ0?=

    Controls reset after postback, why?

    =?Utf-8?B?QXJ0?=, May 25, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    880
    Jimi200478
    May 26, 2006
  4. Ray
    Replies:
    0
    Views:
    144
  5. Robert Oschler
    Replies:
    0
    Views:
    171
    Robert Oschler
    Aug 26, 2003
Loading...

Share This Page