Home > DeveloperSection > Articles > How to use confirmation box using JavaScript

How to use confirmation box using JavaScript


ASP.Net ASP.Net 
Ratings:
0 Comment(s)
 4540  View(s)
Rate this:

How to use confirmation box using JavaScript

This is the simple demonstration in JavaScript how to use confirmation box. Confirmation box are used for check the user confirmation for example you want to delete this item, you want to continue this page etc.

So, this is the simple code how to use confirmation box.

Write this code on aspx page

<head runat="server">

    <title>Sample for Confirmation Box</title>

    <script type="text/javascript">

        function FuncCheck() {

            var strVal = confirm("Are you sure you want to show this content?");

            if (strVal == true) {

                return true;

            }

            else {

                var lblMsg = document.getElementById('lblMsg');

                lblMsg.innerHTML = "";

                return false;

            }

        }

    </script>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="return FuncCheck()"

            OnClick="btnSubmit_Click" />

        <asp:Label ID="lblMsg" runat="server"></asp:Label>

    </div>

    </form>

</body>

 

And write this code at code behind page

protected void btnSubmit_Click(object sender, EventArgs e)

    {

        lblMsg.Text = "This is your content.....";

    }


Don't want to miss updates? Please click the below button!

Follow MindStick