473,769 Members | 7,355 Online
Bytes | Software Development & Data Engineering Community
+ 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_D elete(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs 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 =
ConfigurationSe ttings.AppSetti ngs["BLConnectionSt ring"];
SqlConnection connection = new SqlConnection(c onnstr);
SqlCommand myCommand = new SqlCommand(dele teCmd, connection);
myCommand.Param eters.Add(new SqlParameter("@ profID", SqlDbType.Char,
10));
myCommand.Param eters["@profID"].Value =
dgridProfiles.D ataKeys[(int)e.Item.Ite mIndex];
connection.Open ();
try
{
myCommand.Execu teNonQuery();
dgridProfiles.E ditItemIndex = -1;
LabelMessageAre a.Text = "Profile deleted.";
}
catch (SqlException )
{
LabelMessageAre a.Text = "ERROR: Could not delete record.";
}
finally
{
connection.Clos e();
}
BindGrid();
}

[end code sample]
Thanks!
Nov 18 '05 #1
4 4038
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******** ********@TK2MSF TNGP10.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_D elete(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs 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 =
ConfigurationSe ttings.AppSetti ngs["BLConnectionSt ring"];
SqlConnection connection = new SqlConnection(c onnstr);
SqlCommand myCommand = new SqlCommand(dele teCmd, connection);
myCommand.Param eters.Add(new SqlParameter("@ profID", SqlDbType.Char,
10));
myCommand.Param eters["@profID"].Value =
dgridProfiles.D ataKeys[(int)e.Item.Ite mIndex];
connection.Open ();
try
{
myCommand.Execu teNonQuery();
dgridProfiles.E ditItemIndex = -1;
LabelMessageAre a.Text = "Profile deleted.";
}
catch (SqlException )
{
LabelMessageAre a.Text = "ERROR: Could not delete record.";
}
finally
{
connection.Clos e();
}
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******** ********@TK2MSF TNGP10.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_D elete(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs 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 =
ConfigurationSe ttings.AppSetti ngs["BLConnectionSt ring"];
SqlConnection connection = new SqlConnection(c onnstr);
SqlCommand myCommand = new SqlCommand(dele teCmd, connection);
myCommand.Param eters.Add(new SqlParameter("@ profID", SqlDbType.Char,
10));
myCommand.Param eters["@profID"].Value =
dgridProfiles.D ataKeys[(int)e.Item.Ite mIndex];
connection.Open ();
try
{
myCommand.Execu teNonQuery();
dgridProfiles.E ditItemIndex = -1;
LabelMessageAre a.Text = "Profile deleted.";
}
catch (SqlException )
{
LabelMessageAre a.Text = "ERROR: Could not delete record.";
}
finally
{
connection.Clos e();
}
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
6281
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 simply asks "This will end your session and close the window", then offers a cancel or ok button. Clicking on ok closes both the page it was on, and the confirmation window. Can someone suggest a simple way to do this?
3
1979
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 change it. We thank you for your patronage.". Question. At what point will I be able to delete my cookies? If I delete them before posting the online form, then they won't be available if customers from the confirmation page.
13
8106
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 data was received by the socket on the remote end? Can I count on that? Do I understand TCP correctly in that, it gives confirmation ? I do not expect, that a .Net based receiver got that data when socket.Send() terminates!
6
3709
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 confirmation message. By adding just an confirm attribute for 'onclick' event of the button doesn't work with validation controls. Is there any short way to go around this. Thanks Nedu
0
446
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 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"...
3
2794
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, but users have requested a confirmation message pop up so the user can confirm the delete. I can not quite get this to work. Here are the facts: I am working in the Microsoft Development Environment 2003 (Version
4
3032
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 that page. Each row in each datagrid includes a Delete button (added at runtime by the code-behind page as a ButtonColumn) and an Edit button (added at runtime by the code-behind page as an EditCommandColumn). What is the quickest, easiest and...
3
3829
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
2027
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. For example, I have 2 text boxes and one button. The button will call On_Click event . Sub btnSelect_OnClick(ByVal sender As Object, ByVal e As EventArgs) Dim X as double = CDBL(txtbox1.text) Dim Y as double = CDBL(txtbox2.text)
2
7718
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 submit button to submit a form that contains one or two Mileposts: 1) If a Milepost range larger than 5 miles is entered, I would like to pop up a confirmation box to confirm the range.
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.