Hello
I have a button on a page that inserts a record into a SQL database. The value from a textbox is inserted into a field and then the field is cleared.
After I do this, if I press F5 to refresh - the records is inserted again - I stepped through the code, it does the Page_Load then goes to the Button event
In the Button event, the TextBox.Text ="" after the record is inserted, also I have this IF....
If Trim(TextBox.Text) <> "" Then
' Insert Record
but TextBox.Text still holds the value from the previous page load - so I get the same record inserted
Is there a property on the button I can change? I don't understand why this code is being launched - am I missing a basic principle of postbacks?
I need the code in the button not to fire when the user hits F5 - and why it would and keep the old textbox value.
Thanks in advance
Dave
(VS 2005 ASP.NET)
I have a button on a page that inserts a record into a SQL database. The value from a textbox is inserted into a field and then the field is cleared.
After I do this, if I press F5 to refresh - the records is inserted again - I stepped through the code, it does the Page_Load then goes to the Button event
In the Button event, the TextBox.Text ="" after the record is inserted, also I have this IF....
If Trim(TextBox.Text) <> "" Then
' Insert Record
but TextBox.Text still holds the value from the previous page load - so I get the same record inserted
Is there a property on the button I can change? I don't understand why this code is being launched - am I missing a basic principle of postbacks?
I need the code in the button not to fire when the user hits F5 - and why it would and keep the old textbox value.
Thanks in advance
Dave
(VS 2005 ASP.NET)