Monday, October 14, 2019

Jquery confirmation dialog

Hi,
The code gets asp.net textbox value by jquery then display it in the jquery confirmation dialog.
.aspx page

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="../Scripts/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="../Scripts/jquery-ui.js"></script>
    <link href="../Scripts/jquery-ui.css" rel="stylesheet" />
 
   <script type="text/javascript">
        function verifyUserName() {
         
            customDialog('you have registered ' +
          $('#<%=TextBox1.ClientID %>').val());
      }

        function customDialog(msg) {

            //for yes or no dialog
            $('#div_sexpired').remove();
            var dialog = $('<div id="div_sexpired"></div>').text(msg);
            $('body').append(dialog);

            $('#div_sexpired').dialog({
                autoOpen: false,
                modal: true,
                title: 'Verify User Name',
                buttons: {
                    "OK": function () {

                        $(dialog).dialog('close');
                        $('#div_sexpired').remove();
                    }
                }

            });

            $('#div_sexpired').dialog('open');

        }
     
        </script>


</head>
<body style="background-color:lightblue;">
    <form id="form1" runat="server">
      
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
       <input type="button" id="btn_verifyusername" onclick="verifyUserName();" value="Verify User" />
    </div>
    </form>
</body>
</html>



No comments:

Post a Comment