i have written below code to confirm message before save record into database. but when i impliment inside my project its not working.
Javascript code written into my web page after after head tag.
i have used (!ispostback) in side my project kindly help me what is wrong. the page is not do any process after button press.
- <script type="text/javascript">
- function ConfirmMessage() {
- var selectedvalue = confirm("Do you want to save data?");
- if (selectedvalue) {
- document.getElementById('<%=txtconformmessageValue.ClientID %>').value = "Yes";
- } else {
- document.getElementById('<%=txtconformmessageValue.ClientID %>').value = "No";
- }
- }
- </script>
added hidden field for the store value.
- <asp:HiddenField ID="txtconformmessageValue" runat="server" />
code behind code for save button code.
- if (txtconformmessageValue.Value == "Yes")
- {
- Page.ClientScript.RegisterStartupScript(this.GetType(), "Confirm value", "alert('Record Has Been Saved')", true);
- }
- else
- {
- return;
-
- }