473,466 Members | 1,364 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to show Confirmation message box?

I have a small web app that displays data from a SQL Server database. Using
a DataGrid control on a page, the user can delete a row from the database.
This works fine. But I want to prompt the user for confirmation ("Are you
sure...") before deleting the record. How can I do this from the ASP.NET
code? Since the C# code is server-side, is there a way to display a Yes/No
type of message box and only take action if the users clicks the "Yes"
button? I'm new to web development, so any and all help is appreciated.

Here is the deletion message handler; I want to prompt the user for
confirmation before the deletion code executes:

private void dgridProfiles_Delete(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
[** How do I prompt the user here??]
[If user said yes, then...]
String profID = e.Item.Cells[0].Text.Trim();
String deleteCmd = "DELETE from Profile where ProfileID = @profID";
string connstr =
ConfigurationSettings.AppSettings["BLConnectionString"];
SqlConnection connection = new SqlConnection(connstr);
SqlCommand myCommand = new SqlCommand(deleteCmd, connection);
myCommand.Parameters.Add(new SqlParameter("@profID", SqlDbType.Char,
10));
myCommand.Parameters["@profID"].Value =
dgridProfiles.DataKeys[(int)e.Item.ItemIndex];
connection.Open();
try
{
myCommand.ExecuteNonQuery();
dgridProfiles.EditItemIndex = -1;
LabelMessageArea.Text = "Profile deleted.";
}
catch (SqlException )
{
LabelMessageArea.Text = "ERROR: Could not delete record.";
}
finally
{
connection.Close();
}
BindGrid();
}

[end code sample]
Thanks!
Nov 18 '05 #1
4 4018
Ron... You can do this with client side java script.

http://www.geocities.com/jeff_louie/net_delete.htm

Regards,
Jeff
But I want to prompt the user for confirmation ("Are you

sure...") before deleting the record. How can I do this from the ASP.NET
code? <

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2
Here's an example that should answer your question:
http://www.dotnetjunkies.com/HowTo/1...EB07C94A8.dcik

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"Ron Clarke" <ro********@hp.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a small web app that displays data from a SQL Server database. Using a DataGrid control on a page, the user can delete a row from the database.
This works fine. But I want to prompt the user for confirmation ("Are you
sure...") before deleting the record. How can I do this from the ASP.NET
code? Since the C# code is server-side, is there a way to display a Yes/No
type of message box and only take action if the users clicks the "Yes"
button? I'm new to web development, so any and all help is appreciated.

Here is the deletion message handler; I want to prompt the user for
confirmation before the deletion code executes:

private void dgridProfiles_Delete(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
[** How do I prompt the user here??]
[If user said yes, then...]
String profID = e.Item.Cells[0].Text.Trim();
String deleteCmd = "DELETE from Profile where ProfileID = @profID";
string connstr =
ConfigurationSettings.AppSettings["BLConnectionString"];
SqlConnection connection = new SqlConnection(connstr);
SqlCommand myCommand = new SqlCommand(deleteCmd, connection);
myCommand.Parameters.Add(new SqlParameter("@profID", SqlDbType.Char,
10));
myCommand.Parameters["@profID"].Value =
dgridProfiles.DataKeys[(int)e.Item.ItemIndex];
connection.Open();
try
{
myCommand.ExecuteNonQuery();
dgridProfiles.EditItemIndex = -1;
LabelMessageArea.Text = "Profile deleted.";
}
catch (SqlException )
{
LabelMessageArea.Text = "ERROR: Could not delete record.";
}
finally
{
connection.Close();
}
BindGrid();
}

[end code sample]
Thanks!

Nov 18 '05 #3
Ron... You can do this with client side java script.

http://www.geocities.com/jeff_louie/net_delete.htm

Regards,
Jeff
But I want to prompt the user for confirmation ("Are you

sure...") before deleting the record. How can I do this from the ASP.NET
code? <

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4
Here's an example that should answer your question:
http://www.dotnetjunkies.com/HowTo/1...EB07C94A8.dcik

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"Ron Clarke" <ro********@hp.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a small web app that displays data from a SQL Server database. Using a DataGrid control on a page, the user can delete a row from the database.
This works fine. But I want to prompt the user for confirmation ("Are you
sure...") before deleting the record. How can I do this from the ASP.NET
code? Since the C# code is server-side, is there a way to display a Yes/No
type of message box and only take action if the users clicks the "Yes"
button? I'm new to web development, so any and all help is appreciated.

Here is the deletion message handler; I want to prompt the user for
confirmation before the deletion code executes:

private void dgridProfiles_Delete(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
[** How do I prompt the user here??]
[If user said yes, then...]
String profID = e.Item.Cells[0].Text.Trim();
String deleteCmd = "DELETE from Profile where ProfileID = @profID";
string connstr =
ConfigurationSettings.AppSettings["BLConnectionString"];
SqlConnection connection = new SqlConnection(connstr);
SqlCommand myCommand = new SqlCommand(deleteCmd, connection);
myCommand.Parameters.Add(new SqlParameter("@profID", SqlDbType.Char,
10));
myCommand.Parameters["@profID"].Value =
dgridProfiles.DataKeys[(int)e.Item.ItemIndex];
connection.Open();
try
{
myCommand.ExecuteNonQuery();
dgridProfiles.EditItemIndex = -1;
LabelMessageArea.Text = "Profile deleted.";
}
catch (SqlException )
{
LabelMessageArea.Text = "ERROR: Could not delete record.";
}
finally
{
connection.Close();
}
BindGrid();
}

[end code sample]
Thanks!

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: ScooterMX | last post by:
I have a <a href="javascript:top.window.close()"><img src="exit.gif"></a> tag on my page that closes itself when you click on it. What I NEED is for it to put up a confirmation message that...
3
by: Dennis Allen | last post by:
Hi. On my online ordering form I use browser cookies to keep track of user items. My confirmation page reads: "If any of this information is incorrect, please go back to the order form and...
13
by: Manfred Braun | last post by:
Hi All, I am trying to understand the blocking method socket.Send(). The call blocks as expected, but does this mean, it returnes after the underlying TCP layer got a confirmation, that the send...
6
by: Nedu N | last post by:
Hi, I want to have confirmation(Yes/No) on a button of the webform in which there are many validation controls. I want all the validation controls to be triggered first and then Yes/No...
0
by: Ron Clarke | last post by:
I have a small web app that displays data from a SQL Server database. Using a DataGrid control on a page, the user can delete a row from the database. This works fine. But I want to prompt the user...
3
by: vcornjamb | last post by:
Hello, I am developing a web form that contains some buttons and a data grid which has as its last column link buttons that will delete the data associated with that row. Everything works fine,...
4
by: DrData | last post by:
I'm working on an ASP.Net application written in C#. On one page, there are several datagrid controls used to display, edit and delete detail records relating to the master record also displayed on...
3
by: ad | last post by:
I want user can confirm before delete records ? How can I show a confirm dialog when users press a button?
2
by: bienwell | last post by:
Hi all, I still have a problem when using Confirmation box in ASP.NET program. I need to get the value return of YES or NO from confirmation box in Sub function of VB program to do some tasks....
2
by: bay_dar | last post by:
Hi, I have an internal ASP.NET application that I'm are using to send e-mails out based on a single milepost or milepost range entered. I'm trying to do two things when a user clicks on the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.