Remembering Events

  • Thread starter Thread starter Prince
  • Start date Start date
P

Prince

I have a form with an <asp:textbox id="name" /> control.
I then have the TextChanged event wired for it. If a
user modifies any text within the control, the event
fires. Within the event handler, I flag that the text
has been modified.

ex.
bool nameModified = false;

name_TextChanged(....){
nameModified = true;
}

Now when the user presses the UPDATE button, I check the
modified flag for each control and if it is true, I
update the database with the new data. All this works
fine.

Problem:
I also have validation controls on the page. In the
following sequence the problem occurs.

1) User modifies the 'name' textbox -- modified flag set.
2) User clicks into another textbox -- for some reason,
the browser refreshes.

When the page reloads, the nameModified flag is reset to
false, as it should be. However, I don't want it to be
reset to false. I want the page to remember that
the 'name' textbox has already been modified.

How can I make it remember? Better yet, how can I stop
the page from reloading when I click out of a control?

-- Prince
 
While reading other questions, I accidentally came across
the answer.

Solution: remove the AutoPostBack from the control or set
it to "false".

In case someone else had the same problem.
 
Back
Top