Results 1 to 4 of 4

Thread: How Can i Firing An Alert in asp.net after saving In database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2012
    Location
    Syria
    Posts
    31

    Exclamation 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 ...

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Feb 2012
    Location
    Syria
    Posts
    31

    Re: How Can i Firing An Alert in asp.net after saving In database

    Up ^^^

  3. #3
    Hyperactive Member jasonwucinski's Avatar
    Join Date
    Mar 2010
    Location
    Pittsburgh
    Posts
    452

    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!

  4. #4
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    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
  •  



Click Here to Expand Forum to Full Width