articles

home / developersection / articles / how to use confirmation box using javascript

How to use confirmation box using JavaScript

Amit Singh 7129 22-Feb-2012

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.....";
    }

Updated 29-Nov-2017
Amit Singh

Other


Message

Leave Comment

Comments

Liked By