Ajax Confirmation control.

Last post 05-14-2008 1:15 PM by anas. 5 replies.

Sort Posts:

  • Ajax Confirmation control.

    05-09-2008, 10:27 AM
    • Loading...
    • ddee
    • Joined on 10-03-2006, 6:34 PM
    • Posts 31

    Hi all,

     Does any one know how to do  a double confirmation using AJAX Control?

    for example if i want to delete a record by click a button, i would like to have one AJAX confirm said :  The record selected will be delete... (OK, CANCEL)

    then if i hit OK , it will use another AJAX CONFIRM CONTROL and ask ARE YOU SURE? (YES OR NO)

    Any help would be greatly appreciated. 

    Thanks,

     

    Ddee

  • Re: Ajax Confirmation control.

    05-09-2008, 10:47 AM
    • Loading...
    • anas
    • Joined on 09-21-2006, 4:31 AM
    • Palestine - فلسطين
    • Posts 2,438

    you can accomplish that without the Extendar as follows;

      

            <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:if(confirm('The record selected will be delete... (OK, CANCEL)'))return  confirm('ask ARE YOU SURE? (YES OR NO)'); else return false;"  />
    
     
    Best Regards,

    Anas Ghanem - انس الغانم | My Blog
  • Re: Ajax Confirmation control.

    05-09-2008, 10:53 AM
    • Loading...
    • whatispunk
    • Joined on 03-06-2007, 5:21 PM
    • Winnipeg
    • Posts 514

    Why would you ask your user the same thing twice?

    Why would you ask your user the same thing twice?

    It seems kind of uneccesary doesn't it?

    It seems kind of uneccesary doesn't it?

    Why not mark the data as deleted in the database (soft delete) rather than actually deleting it. Then you can offer the user a way to undo the deletion. Then at the end of the Session you could permanently remove all the entries marked for deletion.

    I know that's more complex, but if I had to click OK, YES everytime I wanted to delete a record I think I'd probably throw my keyboard through the window.

    What do you think?

    What do you think?

    Don't forget to click "Mark as Answer" if someone answers your question. Feel free to mark more than one answer, if you feel so inclined.
  • Re: Ajax Confirmation control.

    05-14-2008, 9:17 AM
    • Loading...
    • ddee
    • Joined on 10-03-2006, 6:34 PM
    • Posts 31

    Hi Anas, 

    Thank you... It work great except that is there a way I can pass in the value at run time that i would like to display in the confirm message????

    Ddee

  • Re: Ajax Confirmation control.

    05-14-2008, 10:21 AM
    Answer
    • Loading...
    • entrodus
    • Joined on 01-17-2007, 9:29 AM
    • Posts 24

    I think you mean something like:
     

        Private Sub AddConfirmation(ByVal msg As String, ByVal btn As Button)
    Dim ConfirmFullFunction As String = "return confirm(""{0}"");" btn.Attributes.Add("onclick", String.Format(ConfirmFullFunction, msg))
    End Sub

     

    Use it like this:
     

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then AddConfirmation("Are you sure you wanted to press this button?", Button1)
    End If
    End Sub
     
  • Re: Ajax Confirmation control.

    05-14-2008, 1:15 PM
    Answer
    • Loading...
    • anas
    • Joined on 09-21-2006, 4:31 AM
    • Palestine - فلسطين
    • Posts 2,438

    ddee:
    is there a way I can pass in the value at run time that i would like to display in the confirm message

    Yes, you can assign the OnClientClick Property from code behind , for examlpe , in page_Laod  you can write this :

     

      If Not IsPostBack Then
                ' the message that will be displayed to the user 
                ' you can change the message Text as you want 
                Dim FirstAlert As String = " First Confirm  Message goes here  "
                Dim secondalert As String = "Second Confirm Message goes here  "
    
                Button1.OnClientClick = _
                String.Format("javascript:if(confirm('{0}'))return  confirm('{1}'); else return false;", FirstAlert, secondalert)
            End If
    

     

    the FirstAlert and SecondAlert variables  can be  assigned to value from your language resource so that you can Display a locaized messsages,

    To access the Global Resource File Or Page Local File , you can use

    HttpContext.GetGlobalResourceObject  Or Httpcontext.GetLocalResourceObject methods

     

     

    Best Regards,

    Anas Ghanem - انس الغانم | My Blog
Page 1 of 1 (6 items)