-
Nov 11th, 2012, 10:19 AM
#1
Thread Starter
Junior Member
How Can i Firing An Alert in asp.net after saving In database
Hi all
I'm New In Asp.net , And I Wanna to know how can i display an alert to the user that inform the saving operation was done successfully and refresh the page to clear all the textboxs in the form to insert a new record in database ??
can any one help me ??
Best Regards ...
-
Nov 11th, 2012, 05:17 PM
#2
Thread Starter
Junior Member
Re: How Can i Firing An Alert in asp.net after saving In database
-
Nov 14th, 2012, 08:28 AM
#3
Hyperactive Member
Re: How Can i Firing An Alert in asp.net after saving In database
It seems like you have two issues: First, determining if a save was successful. Second, alerting the user. The first issue can be addressed in a few ways. I use transactions. This way, if you submit one or more insert/updates to the database and an error occurs, all transactions fail. Through the use of error catching, you can then determine if an insert/update/delete was successful. If you catch an error, you know if failed otherwise, it must have succeeded.
To display this to the user: I use update panels. When the user submits the request (ie: clicks a button to add a record(s)) the update panel fires a request to the server, which is where you would send your request to the db. Once the request has been completed, return a value that can be displayed. Or, if you dont want to use update panels, you can just have the page redirect to a page that does the work, then redirect according to whether the database process was successful or not.
if i was able to help, rate my post!
-
Nov 18th, 2012, 07:29 PM
#4
Frenzied Member
Re: How Can i Firing An Alert in asp.net after saving In database
Or do something easy, like a boolean, if the save is successful, display a message on the page that says Save Successful and Clear the Text boxes, e.g.:
Code:
if SaveToDataBase() then
labelMessage.Visible = true
labelMessage.Text = "Saved successfully"
myTextBox1.Text = ""
myTextBox2.Text = ""
else
labelMessage.Visible = true
labelMessage.Text = "Error saving"
end if
Lot's of fancier ways to do it as suggested above, but you can always start simple.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|