473,386 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 DataGridCommandEventArgs event occured.

Expand|Select|Wrap|Line Numbers
  1. protected void SetDeleteButton(Object sender, DataGridCommandEventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 if (e.CommandName == "Delete")
  6.                 {
  7.                     grdAdminAccount.EditItemIndex = -1;                    
  8.                     if (e.Item.Cells[1].Text.ToLower() != "admin")
  9.                     {
  10.                         Management.DeleteAdmin(e.Item.Cells[1].Text, Convert.ToInt16(e.Item.Cells[0].Text));
  11.  
  12.                         string popupScript = "<script language='javascript' >" + "alert('The Administrator account is successfully deleted.');" + "</script>";
  13.                         Page.RegisterStartupScript("PopupScript", popupScript);
  14.  
  15.                         if (grdAdminAccount.CurrentPageIndex > 0 && e.Item.ItemIndex == 0 && grdAdminAccount.Items.Count <= 1)
  16.                         {
  17.                             grdAdminAccount.CurrentPageIndex = grdAdminAccount.CurrentPageIndex - 1;
  18.                         }
  19.  
  20.                         FileGrid();
  21.                     }
  22.                 }
  23.             }
  24.  catch (Exception ex)
  25.             {
  26.                 Response.Redirect("default.aspx?action='Error'", false);
  27.             }      
  28.         }
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
Apr 22 '10 #1
2 2387
Monomachus
127 Expert 100+
@PrasathPalani
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.
Apr 22 '10 #2
tlhintoq
3,525 Expert 2GB
TIP: When you first created your question you were asked to wrap your code with [code] tags.

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.
Apr 22 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: PH | last post by:
Does anyone know how to have the pop-up javascript alert, Response.Write("<script language=javascript>alert('HEY!');</script>); , pop-up after the page has been posted back? I am pressing a...
14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
4
by: PH | last post by:
Does anyone know how to have the pop-up javascript alert, Response.Write("<script language=javascript>alert('HEY!');</script>); , pop-up after the page has been posted back? I am pressing a...
1
by: PH | last post by:
Does anyone know how to have the pop-up javascript alert, Response.Write("<script language=javascript>alert('HEY!');</script>); , pop-up after the page has been posted back? I am pressing a...
3
by: Ersin Gençtürk | last post by:
hi, I wrote a function like this : public static void Alert(string message){ message=message.Replace("'","\'"); message=message.Replace("\n","\\n"); ...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
7
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the...
4
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
1
Frinavale
by: Frinavale | last post by:
Introduction I've seen many questions asked about how to disable the browser's back button and in the past I've replied with "it's simply not possible". It's not a good idea to disable the back...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.