简体   繁体   中英

How to display “yes” or “no” message box in asp.net?

I want to display a message to the user to select yes or no . According to the clicked button(Yes or no), the value should be passed to a query as a parameter . How can I do this. This is what I have done so far.

  <script type="text/javascript"> function confirm() { var confirmValue = document.createElement("INPUT"); confirmValue.type = "hidden"; confirmValue.name = "confirmValue"; if (confirm("Do you want to finalize? If you click yes, you will not be able to update and application will be passed to the MBD Coordinator")) { confirmValue.value = "YES"; } else { confirmValue.value = "NO"; } document.forms[0].appendChild(confirmValue); } </script> 
 <asp:Button ID="btnFinish" runat="server" Text="Finish" BorderStyle="Solid" BorderColor="#9B0423" Font-Bold="true" Width="100px" Height="30px" ForeColor="#9B0423" Style="margin-right:20px;" OnClick="btnFinish_Click" OnClientClick = "confirm()"/> 

This is the C# code

string confirmValue = Request.Form["confirmValue"];
if (confirmValue == "Yes")
{
      string value = "YES";
}
else
{
      string value = "NO";
}                  

But in this I don't get a message to select any option.

Change the name of the function from "confirm" to something else. You are overriding the default confirm function in JavaScript.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM