JavaScript Alert message occured when back button pressing to navigate.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PrasathPalani
    New Member
    • Apr 2010
    • 1

    JavaScript Alert message occured when back button pressing to navigate.

    Dear Experts,

    I have a Datagrid with delete options. I use to confirm from users and delete record from data grid. I give confrimation after each record has deleted when a DataGridCommand EventArgs event occured.

    Code:
    protected void SetDeleteButton(Object sender, DataGridCommandEventArgs e)
            {
                try
                {
                    if (e.CommandName == "Delete")
                    {
                        grdAdminAccount.EditItemIndex = -1;                    
                        if (e.Item.Cells[1].Text.ToLower() != "admin")
                        {
                            Management.DeleteAdmin(e.Item.Cells[1].Text, Convert.ToInt16(e.Item.Cells[0].Text));
                            
                            string popupScript = "<script language='javascript' >" + "alert('The Administrator account is successfully deleted.');" + "</script>";
                            Page.RegisterStartupScript("PopupScript", popupScript);
                            
                            if (grdAdminAccount.CurrentPageIndex > 0 && e.Item.ItemIndex == 0 && grdAdminAccount.Items.Count <= 1)
                            {
                                grdAdminAccount.CurrentPageIndex = grdAdminAccount.CurrentPageIndex - 1;
                            }
    
                            FileGrid();
                        }
                    }
                }
     catch (Exception ex)
                {
                    Response.Redirect("default.aspx?action='Error'", false);
                }      
            }
    But when i am navigating to some other pages and press the back button this delete confirmation popup occured once again. How to handle it.

    Please do it need full.

    Regards,
    Prasath
    Last edited by tlhintoq; Apr 22 '10, 03:24 PM. Reason: [CODE] ...Your code goes between code tags [/CODE]
  • Monomachus
    Recognized Expert New Member
    • Apr 2008
    • 127

    #2
    Originally posted by PrasathPalani
    Dear Experts,

    I have a Datagrid with delete options. I use to confirm from users and delete record from data grid. I give confrimation after each record has deleted when a DataGridCommand EventArgs event occured.

    protected void SetDeleteButton (Object sender, DataGridCommand EventArgs e)
    {
    try
    {
    if (e.CommandName == "Delete")
    {
    grdAdminAccount .EditItemIndex = -1;
    if (e.Item.Cells[1].Text.ToLower() != "admin")
    {
    Management.Dele teAdmin(e.Item. Cells[1].Text, Convert.ToInt16 (e.Item.Cells[0].Text));

    string popupScript = "<script language='javas cript' >" + "alert('The Administrator account is successfully deleted.');" + "</script>";
    Page.RegisterSt artupScript("Po pupScript", popupScript);

    if (grdAdminAccoun t.CurrentPageIn dex > 0 && e.Item.ItemInde x == 0 && grdAdminAccount .Items.Count <= 1)
    {
    grdAdminAccount .CurrentPageInd ex = grdAdminAccount .CurrentPageInd ex - 1;
    }

    FileGrid();
    }
    }
    }
    catch (Exception ex)
    {
    Response.Redire ct("default.asp x?action='Error '", false);
    }
    }

    But when i am navigating to some other pages and press the back button this delete confirmation popup occured once again. How to handle it.

    Please do it need full.

    Regards,
    Prasath
    I think it has more to do with ASP.NET because I'm assuming you use Datagrid web control. Am I right? If so you should move this thread there.

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      TIP: When you first created your question you were asked to wrap your code with [code] tags.
      [imgnothumb]http://files.me.com/tlhintoq/10jihf[/imgnothumb]
      It really does help a bunch. Look how much easier it is to read now that someone has done it for you. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

      Comment

      Working...