OK and Cancel option (confirmation)

I want to do provide ok and cancel option with ASP.Net button.

Scenario : User will click on the button "Get Price". I will call some procedures / database call and manipulate some data and will calculate price.

I want to show messagebox to user say ex.  "The calculated price is: 12.34. Do you want to proceed?". with OK and Cancel option.

If user press OK then proceed with further operation and cancel will not do anything.

 Please suggest me the code. Thanks


4/2/2008 4:40:26 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

7 Replies

Similar Articles

[PageSpeed] 56
Get it on Google Play
Get it on Apple App Store

<asp:Button ID="myButton" runat="server" Text="Get Price" OnClientClick="return confirm('Are you sure?');" />

When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.

My latest ASP.NET AJAX blog entries.
4/2/2008 5:03:27 PM

 you an use ajax modal pop up xtender:

check out: 




~ Remember To Mark The Post(s) That Helped You As The ANSWER ~
4/2/2008 6:09:06 PM

If your button id is button1, do this:

button1.OnClientClick="return confirm('Are you abosulutely sure you want to do this?');"

4/2/2008 6:46:28 PM

I want to do server calls / db calls , calculate price. And after calculating price, wish to display message

"The price is : 13.52", Do you want to proceed?"


4/3/2008 9:51:46 AM

if you want to do in the middle of your code means after pressing button you will cal some thing and after that you want to display message then this is not possible in web application .If you want do display message on button click and if you will press ok the code will execute else not then many one have give you write solution above you can chose one of them.

but what i got you want that after pressing button there will some cal and after these cal there will be message this can happen only in windows application

i think so

4/3/2008 10:04:38 AM

Anonymous2304 :

I want to do server calls / db calls , calculate price. And after calculating price, wish to display message

"The price is : 13.52", Do you want to proceed?"

Hi Anonymous2304  ,

One way to achieve that is using the ASPNET HiddenField Control to pass the calculated price and retrieve it at the CLient side.. see below for demo

<script type="text/javascript" language="javascript">

function confirm()

  var price = document.getElementById('<%= HiddenField1.ClientID %>').value;

  if (confirm("The price is:"+ "" + price + "" + ",Do you want to proceed?")==true)
    return true;
    return false;

</script >

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" OnClientClick="return confirm();" />
<asp:HiddenField ID="HiddenField1" runat="server" />

Another way around is to create you own Message Popup using Divs with CSS styles... 

Hope that Helps! 



"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
4/3/2008 10:06:58 AM

put this code in your button property named onClientClick    return confirm("your message?")

4/3/2008 11:32:23 AM

Similar Artilces:

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Confirm Message Box with OK or Cancel option in C#
Hi  All, I have a function call which  results in two conditions(True and False).When the condition is false,I wanted the code to display a message box with the two options (OK and Cancel) and when the user clicks the OK button It should direct to another page. Please anyone help me with the code ( in C# ) to display a confirm message box with this two options.Its urgent. Thanks for your help.     private void button3_Click(object sender, System.EventArgs e) { if (MessageBox.Show("Really delete?","Confirm delete", MessageBoxButto...

windows forms in vb .net into web forms
we are creating a database driven website as part of our project. currently we have forms connecting to the database created in visual basic. these windows forms we need to convert into web forms which are asp .net compatible. can u give me an answer or show me a way. Hi, because of the difference in nature between web and win applications you'll need to reimplement at least the UI part. If you have a multitiered application in which the busines logic and data access are in different parts/assemblies you can reuse them. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Wor...

.Net Web Form & Web Service Deployment
Hi all I have written some test web services and some web form applications and deployed them to my IIS. That's fine but I now want to deploy them to my real IIS server. I have created an msi for each but the problem is I seem to only be able to deploy to the default web site. Our default web site is turned off and instead we use several other sites. Does anybody happen to if Powerbuilder 11 supports non default web sites? If not do I need to hack the msi and if so can anybody suggest a suitable tool. I have Orca but it's not very friendly. Unless of course I knew exactly w...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

For interrupting.web form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form
Web Form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form ! Because of my pool English, if you can't see , I will explain more ! ThanksGambler is the real life I guess you mean when form grows it also grow parent div element. This is normal. If you want div to stay fixed size and rather clip the form and maybe show a scrollbar, look at overflow property in CSS.Thanks------------------------------------------------------------This posting is provided "AS IS" with no warranties, and confers no ...

How to fire events in other web form from other web form ?
Suppose that I have A and B web form. I want to trigger B web form's Page_Load event from A web form. How can I do that ? Thanks in advanced WilbertWilbert Bujn Create a public method in B that call the load method : public void Load(object sender, System.EventArgs e) { Page_Load(sender, e) ; } In the page_load of A, instanciate a B object and then call the function B myB = new B() ; myB.Load() ; Quicky Thank you quicky, it works fine. WilbertWilbert Bujn...

Could PB .NET Web Form POST security Information to others web page??
This is a multi-part message in MIME format. ------=_NextPart_000_00F9_01C9C4D5.8FB45C90 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable Hi,=20 Have anyone came across the requesion to POST security informations from = PB .NET web form web page to other web site?? I have tried many datys, Could any kind man give me some suggessions?? thanks & Best regards Leon ------=_NextPart_000_00F9_01C9C4D5.8FB45C90 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML P...

.Net Web Forms
what is the best way to create a multi-page web insurance quote form (similar to Geico) that will insert information into a database? The examples i've seen show one form with a submit button at the bottom. I need to break this form into at least three different aspx or ascx pages. Thanks for the help. I did something similiar since I have like 7 sections to an application. The way I did it was by using the asp:panel control. When the user finished one section and clicks a button it inputs the data into the database and hides the 1st panel and shows the next one. HTH...

confirm ,ok, cancel
hi I am using 2 buttons named edit and update. in asp.net and c#. There is one textbox control named "txtSelectionsNew". there is 1 datagrid.,it is having bound column edit i.e push button. when i click edit button in datagrid,the corresponding fields will display into textfiled named txtselectionsnew. at that time i am making readonly for this text control true. after clicking on edit,i'll change that textbox control and i'll do update by clicking on update.for updation i wrote one function. when i click on update button,confirm box will show ok,cancel. for this i wrote javascript c...

Include web form inside web form
I tried to include an aspx file in a asp.net web form. However, all the web controls (textbox, button) in the included page are not displayed when called. <Form id="Form1" method="post" runat="server"> <%   Response.writeFile("subPage.aspx"); %> <asp:button id="btnPrev" runat="server" text="Previous"></asp:button> </Form> There are some <asp:textbox> controls in the subPage.aspx file, the file itself works fine, but when it is included in the main page, all the controls are not displayed. Please assist. Thanks   u should u...

Web Form embedded in another Web Form
Hi,  I have programmed a Web Form which acts like a scientific calculator. I would like to embedd this calculator in the upper left hand corner of another accounting Web Form. I don't want to host the calculator on the same server as the accounting page. I.e. I want them to have distinct URLs. Classically, I would do this using frames, but is there a better way using ASP? Is there some sort of Panel which can display the webpage at a specific URL which I can just drag onto my accounting Web Form? Thanks,  P1000   Frames are the only way to embed a webform inside ano...

How To Convert c#2005.net web template to vb2005.net Forms Template
I need  Convert c#2005.net web template to vb2005.net Forms Template   There are some free c# to vb converters out there which will allow you to upload a project and convert it to vb.   The programming models for windows forms and web projects are very different there is no way to convert a web to windows forms project.   http://www.carlosag.net/Tools/CodeTranslator/Default.aspx      Silverlight-helpVb TipsSpace Coast .Net User Group Hey Ajax-y, This tool really helps all programmers. I thought I would share this wit...

Web resources about - OK and Cancel option (confirmation) - asp.net.web-forms

Confirmation - Wikipedia, the free encyclopedia
A bishop administering Confirmation. Rogier van der Weyden , The Seven Sacraments , 15th century. normally carried out through anointing , the ...

Confirmation - Wikipedia, the free encyclopedia
A bishop administering Confirmation. Rogier van der Weyden , The Seven Sacraments , 15th century. normally carried out through anointing , the ...

Facebook Reportedly Acquires Gowalla, No Confirmation From Either Company
... “most” of its employees and founder Josh Williams over to Palo Alto headquarters to work on Timeline, according to CNN. We could not get confirmation ...

Twitter reactions to the #Fed confirmation
... over Twitter — the last time that a new chairperson was appointed, Twitter wasn’t around. Within half an hour of the milestone confirmation, ...

Senate Confirmation Hearing (200910150008HQ) - Flickr - Photo Sharing!
U.S. Sen. Jay Rockefeller, D-W.Va., Chairman of the of the Senate Committee on Commerce, Science and Transportation, makes a point during the ...

John Kerry Confirmation Hearing: Questioned About Vietnam vs. Current U.S. Policy - YouTube
Secretary of State nominee, a vet who later protested Vietnam, faces questions from Sen. Rand Paul.

Republicans force delay on Hagel confirmation
... answers from US President Barack Obama's pick to head the Pentagon have forced Senate leaders to delay a vote, throwing Chuck Hagel's confirmation ...

Is this confirmation Prince George and Princess Charlotte's nanny is Mary Poppins?
The christening of Princess Charlotte was touted as &quot;modern&quot;. No one told the nanny.

Jurgen Klopp Liverpool, Jurgen Klopp news, Jurgen Klopp Liverpool confirmation
JURGEN Klopp is officially the new Liverpool manager.

Is this confirmation Prince George and Princess Charlotte's nanny is Mary ...
Sydney Morning Herald Is this confirmation Prince George and Princess Charlotte's nanny is Mary ... Sydney Morning Herald There were many ...

Resources last updated: 12/4/2015 9:26:10 PM