Click here to Skip to main content
15,848,415 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

Can any one tell me, how to display a message box in web using JavaScript?

I already found code from Google for displaying msgBox in web. But, it is confirm box only which displays OK and CANCEL buttons on it..

I need to display a message box in web in JavaScript with YES and NO buttons..

Is there any code to display like that?

Thanks & Warm regards,


You cannot modify confirm box of javascript. Take a look at jQuery options.[^]
Share this answer
Share this answer
use this :-
public static void MessageBox(System.Web.UI.Page senderPage, string alertMsg, string alertKey)
          string strScript = "<script language=JavaScript>alert('" +alertMsg + "')</script>";
          if (!(senderPage.IsStartupScriptRegistered(alertKey)))
              senderPage.RegisterStartupScript(alertKey, strScript);

and call from aspx.cs with Three parameter
try this.
Share this answer
You can use this :
<script language="javascript">
    function window.confirm(str) {
        execScript('n = msgbox("' + str + '","4132")', "vbscript");
        return (n == 6);

But this only works in IE
So better to use jquery ui : Jquery UI
Share this answer
Dalek Dave 4-Oct-11 3:40am    
Edited for Code Block
<script type="text/javascript">
function show_alert()
alert("Project has been add");

<input type="button" onclick="show_alert()" value="Save" />


or for sample...[^]
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