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.
 
 
9
divseep
2/17/2009 8:46:51 AM
📁 asp.net.web-forms
📃 93655 articles.
⭐ 6 followers.

💬 6 Replies
👁️‍🗨️ 145971 Views


private void button3_Click(object sender, System.EventArgs e) 
{
   if (MessageBox.Show("Really delete?","Confirm delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
   {
       // a 'DialogResult.Yes' value was returned from the MessageBox
       // proceed with your deletion
   }
}

Avantha Siriwardana
Beware of bugs in the above code; I have only proved it correct, not tried it.
(Donald Knuth)

-9
AvanthaSiriwardana
2/17/2009 9:12:20 AM

divseep:

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.

 

 


Please refer to the following code:
    protected void Button1_Click(object sender, EventArgs e)
    {
        ClientScriptManager CSM = Page.ClientScript;
        if (!ReturnValue())
        {
            string strconfirm = "      

Similar Artilces:

Problem dealing with the confirm message box in C#.net
Hi..i am actually trying to do something like this.When a user select a particular option from a dropdown list and click a 'Go' button, a confirm message box will be displayed if the user has selected that particular option.Other options selected will not display that confirm box when the 'Go' button is clicked.Once the user press the ok button on the confirm box,it will proceed to perform other tasks.How do i do that?..I try using the following code but it doesnt really work..the confirm box will always popup everytime the 'Go' button is clicked except for the first time u clicked on it. ...

how to call a c# function if user click on ok button of java script confirm box in .net
hi, i have one problem that is i'm adding the new user to database, if that user is already exist in the database one pop up should display with message like 'user already exists are u sure you want to update the role of the user' with 'yes' and 'no ' buttons on pop up, if user click on 'yes' button then it should call edituser() method of c3.net other wise it should reset the selected controls. how to do this using extenal .js file with javascript confirm box   Hi When user click on "Yes" set a asp.net hidden field value to be "true" or "1", if user clicks on "No/Cancel" set the hidden field to be "false" or "0". Based on the hidden field value call C# function in C#.  Shekar.Y(GGKTech)http://ggktech.comDont forget to click “Mark as Answer” on the post that helped you. can u please provide me one example how to do that one This article show how to call C# function from javascript http://forums.asp.net/t/999909.aspx http://www.dotnet247.com/247reference/msgs/30/153188.aspx    Vikram www.vikramlakhotia.comPlease mark the answer if it helped you i'm not able to do can u please provide me how to declare hidden filed values and how to set those to confirm of javascript. i did like this:void getSelectedUserDetails()    {        newConnection.Open();     ...

Load Text box of one web form with selected list item of list box of another web form
one help please Problem is i have two web forms  1.  ForiegnkeyTest.aspx  2. foroginkeytable.aspx   step 1 1 ForiegnkeyTest.aspx one web form     <         
       
       
           step2 . foroginkeytable.aspx ( tiena una listbox cargando sobre base de datos
       
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 with you in hopes that you will fine some use for it. Thanks to KamalPatel.Net for this tool. You can see the tool here. www.kamalpatel.net  Hope this helps!!    Please give us feedback no matter whether you get your answer.Please "mark as answer" if it's useful for youSincerely,SpongeBert...

C#.NET WEB APPLICATION
hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. http://samples.gotdotnet.com/quickstart/aspplus/AbiBaby (Abishek Bellamkonda)=(:-*http://abibaby.wordpress.com...

Web Forms Message Box
Hello, I am converting an old VB 6.0 application into a web based app with VB.NET and ASP.NET. The problem that I am having is that the old application made extensive use of popup boxes and message boxes that would ask the user a couple questions and then pass the values back to the main form and close the popup box. I have not been able to find a good way to do this using web forms. Does anyone have any suggestions on this? Thanks Torrey You will have to use vbscript or javascript to display message boxes on the client side. You can use something like this: Button1.Attr...

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  
OK/Cancel Message box
Hi can anyone please tell me the code to include a Confirm Javascript message box in my VB.NET project...Or can some please point me to a website where i can follow an example Many Thanks Below article has info on CLient side messagebox http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/clientsidescript.aspSreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti Thank you...

Message Boxes and Web Forms
When I go to display a MsgBox(".... in my web form I get an error. Is it possible to display simple pop up messages while working with the web forms?If you don't live for something, you'll DIE for nothing!!!!!! Hi, Message Boxes are not available in asp.net. You need to write custom javascript functionality for popping up messages. Herebelow is one example:- Response.Write("