How come form.reset() doesn't work after postback on this page?

A student in my class brought this to my attention, and I didn't have an explanation for it-- and I couldn't find one after searching.

After clicking the submit button, the reset button does not work. It's as if the browser prevents reset if the resource has been requested via post request.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<script runat="server">


<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
            <legend>User Form</legend>
            <label for="Username"></label>
            <asp:TextBox ID="Username" runat="server"></asp:TextBox>
        <asp:Button runat="server" Text="Submit" />
        <input type="button" onclick="window.document.forms[0].reset()" value="reset" />



When you click reset then the entries are reset to the default values. Default values are values which were rendered by the server in the first case it was empty string but after post the posted value. (http is stateless protocol) If you try to edit the posted value then click reset you will see that the originally posted value will be restored.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.