aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies show the confirmationbox using javascript

Dec 31, 2010

Here I will explain how to show the confirmation box using JavaScript in


I have one button whenever user clicks on that button I need to show one confirmation box if user clicks on ok button I need to execute code in button click event or if he clicks on cancel button nothing to display and the page should not be postback. How we can implement that one in our application? To implement this concept follow these steps

Design your aspx page like this 

<html xmlns="" >
<head runat="server">
<title>Confirmation Box Example</title>
<script type="text/javascript">
//Confirmation box sample
function ConfirmationBox() {
var result = confirm("Are you sure you want to continue?");
if (result == true) {
return true;
else {
var lbl = document.getElementById('lbltxt');
lbl.innerHTML = "";
return false;
<form id="form1" runat="server">
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
OnClientClick="return ConfirmationBox()" onclick="btnSubmit_Click" />
<asp:Label ID="lbltxt" runat="server"></asp:Label>
In code behind button click event write the following code 

protected void btnSubmit_Click(object sender, EventArgs e)
lbltxt.Text = "Welcome to Confirmationbox page";

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Anonymous said...

nice blog bro. where do you work

immu said...

Hi suresh,I need to take one combo box and in dat combo box i need to bind the all stored procedures from backend,by clicking on particular s.p. below the combo box i need to display how many parameters required for a selected s.p.(i need to display dat parameters in a lables) then i need to enter the data and the data should be displayed in a gridview on button click(button name is execute)..This is the exact requirement..can u help me plz..

anusha said...

sir pls help me to use javascript in child page which is derived from master works in normal page

sudharsan said...

very good post

Anonymous said...

hello suresh,

Can I override window.confirm function options Yes,No insted of Yes,Cancel?

if we do this can you provide code for this?

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.