Click here to Skip to main content
15,910,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am using the below message box in asp.net web application. Now i want to convert this message box as a confirmation message box and do something when it is true else means reject the application.
How do I use If condition here

What I have tried:

ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "confirm('Address,Phone Number,Email ID Is Empty Do You Want To Continue');", true);
Posted
Updated 31-May-16 20:58pm
Comments
Sergey Alexandrovich Kryukov 1-Jun-16 2:52am    
What do you mean by "how to use If"? The way it is defined in JavaScript. You have to learn JavaScript before doing some programming. "if" is one of the most basic programming features.
—SA

1 solution

The use of JavaScript window.confirm with if (if not with if then why?) is quite clearly explained, for example, here: Window.confirm() - Web APIs | MDN[^].

But could it be considered as a good solution? I would not say so, not for production-quality applications. Such methods give ugly look depending on the platform and browser, which may not be in line with your application styles, and badly limited in flexibility.

It would be much better to develop modal-like behavior inside a Web page, and do it fully locally, with JavaScript. The first solution would be this: https://jqueryui.com/dialog[^].

Also, there are many 3rd-party jQuery plug-ins, collectively known as "modal popup", with different effects, such as transitions, and, notably, dimming of the rest of the page. Please see: http://bfy.tw/AJH[^].

If you need to learn jQuery (highly recommended), please see:
http://en.wikipedia.org/wiki/JQuery,
http://jquery.com,
http://learn.jquery.com,
http://learn.jquery.com/using-jquery-core,
http://learn.jquery.com/about-jquery/how-jquery-works (start from here).

But you don't have to do it like that. In my article Modal Popup From Scratch I explain how to it and explain the behavior and the rationale behind this design element.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900