Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

how to use popup on click of save button?
suppose btnSave_click is the event
btnSave_click ()
{
  if(<somecondition>)
  {
    // Here i need a popup with two message like continue and cancel
  }
}
Posted
Updated 27-Jan-11 3:12am
v4
Comments
Sandeep Mewara 27-Jan-11 9:08am    
The answers here are just because of you not tagging the question properly nor mentioning in your description that you are working/talking of ASP.NET application.

MessageBox.Show("Do you really want to continue?",
                "Delete Warning", MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false)
                == DialogResult.Yes)
 
Share this answer
 
if (MessageBox.Show("Message Text", "Message Title", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
     //user chose yes
}
else
{
     //user chose no
}
 
Share this answer
 
Comments
Mithun P 27-Jan-11 8:54am    
this wont work in asp.net2.0 c#..i am not getting MessageBox
Ryan Zahra 27-Jan-11 9:02am    
Are you working on a windows application or a web application? Please provide more information!!
Sandeep Mewara 27-Jan-11 9:08am    
OP surely is talking of ASP.NET :doh:
Ryan Zahra 27-Jan-11 9:10am    
Now its obvious, but it was never specified...
Sandeep Mewara 27-Jan-11 9:15am    
Dont worry, not blaming you. Op's mistake - check my comment to the question,.
Based on your scenario, you can use RegisterClientScriptBlock[^] or RegisterStartupScript[^]

You need to inject script through code. Clientside Javascript is the way to raise a messagebox/popup/etc. Have a look at sample article here: How to Use RegisterClientScriptBlock & RegisterStartupScript[^]
 
Share this answer
 
You can also achieve something similar using button's OnClientClick property. Define a JavaScript method and attach that with the button using the OnClientClick property. Now, in JS, based on whatever condition you can directly raise a messagebox or some new window. This would be more straight forward and easy to handle.
 
Share this answer
 
hello,

You also can try the ASP.NET Popup Control[^] I haven't try it myself, but this article has a very good review.
 
Share this answer
 
MIDL
btnSave_click ()
{
  if(<somecondition>)
  {
    // Here i need a popup with two message like continue and cancel
    if(confirm('whatever!')
    {
        //...
    }
  }
}
 
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