Check Username Availability In Asp.net Using Jquery Ajax

Here we will see how to check for username availability using Jquery Ajax method in asp.net. In our website we normally keep the username unique and so it must be checked before saving the record that it has not been taken by any other user. We can do this validation on the submit button click or use OnTextChanged event but it is not so user friendly as the page gets Postback.

Following example demonstrates the same using Jquery Ajax method. Here while creating a user account he can check by making an Ajax call to asp.net [Web Method] at server side to get the availability of the username. It matches the user input against the database records and returns the text based on the availability. You can modified the code as per your requirements:

Continue reading Check Username Availability In Asp.net Using Jquery Ajax

Advertisements

Fill Asp.Net DropDownList With Json Data (JQuery)

Here we will see how to fill asp.net dropdownlist control with json data.

Code is as follows: Continue reading Fill Asp.Net DropDownList With Json Data (JQuery)

Prevent Cut, Copy And Paste Operation For Text Box In Asp.Net Using Jquery.

Here we will see how to block a user from performing CUT, COPY and PASTE operation on a particular textbox using jQuery. Sometimes it is required to disable the cut copy paste operation and make user mandatory to type the details.

The code is as follows: Continue reading Prevent Cut, Copy And Paste Operation For Text Box In Asp.Net Using Jquery.

Check-Box List Validation In Asp.net

Here we will see how to validate check box list control in asp.net. We will use javascript and custom validation to implement this functionality.
The code is as follows:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function CheckboxValidation(sender, args) {
            var checkBoxList = document.getElementById("<%=chk_list1.ClientID %>");
            var checkboxes = checkBoxList.getElementsByTagName("input");
            var isValid = false;
            for (var i = 0; i < checkboxes.length; i++) {
                if (checkboxes[i].checked) {
                    isValid = true;
                    break;
                }
            }
            args.IsValid = isValid;
        }       
    </script>
</head>
<body>
    <form id="form1" runat="server">        
        <div>
            <asp:CheckBoxList runat="server" ID="chk_list1">
                <asp:ListItem Text="Example 1" Value="Example 1"></asp:ListItem>
                <asp:ListItem Text="Example 2" Value="Example 2"></asp:ListItem>
                <asp:ListItem Text="Example 3" Value="Example 3"></asp:ListItem>
                <asp:ListItem Text="Example 4" Value="Example 4"></asp:ListItem>
                <asp:ListItem Text="Example 5" Value="Example 5"></asp:ListItem>
                <asp:ListItem Text="Example 6" Value="Example 6"></asp:ListItem>
            </asp:CheckBoxList>
            <asp:CustomValidator ID="Checkbox_CustomValidator" runat="server"
                ValidationGroup="CheckBoxValidation"                
                Display="None"
                ClientValidationFunction="CheckboxValidation"                                
                ErrorMessage="One or more checkboxes must be chosen">
            </asp:CustomValidator>
            <asp:Button runat="server" ID="btn_submit" Text="Validate" ValidationGroup="CheckBoxValidation" />
            <asp:ValidationSummary runat="server" ID="validateionsummary" ValidationGroup="CheckBoxValidation" ShowMessageBox="true" ShowSummary="false" />
        </div>
    </form>
</body>
</html>

Check Un-check All CheckBox Inside A Repeater

Here we will see how to check uncheck all items in repeater using jQuery. Here we have an additional checkbox (Select All) which will be used to check all the checkboxes that are present in the repeater control.

The code is as follows: Continue reading Check Un-check All CheckBox Inside A Repeater

Display Line Break In Javascript Alert Message Box.

Here we will see how to add a new line break (<br/>) to javaScript alert message box.

To implement this functionality you have to use new line character (\r\n).

Code is as follows: Continue reading Display Line Break In Javascript Alert Message Box.

JQuery UI Autocomplete Textbox Using AJAX Page/Web Method Asp.net

Here we will see how to implement auto complete textbox functionality using jquery ajax call to web method. There are times when we need to show data to user without a post back. We can call the code behind method(Server side method) with jquery ajax.

The code is as follows: Continue reading JQuery UI Autocomplete Textbox Using AJAX Page/Web Method Asp.net