</head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="scriptmanager1" runat="server"> </asp:ScriptManager> <script type="text/javascript"> Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler); function BeginRequestHandler(sender, args) { var state = document.getElementById('loadingdiv').style.display; if (state == 'block') { document.getElementById('loadingdiv').style.display = 'none'; } else { document.getElementById('loadingdiv').style.display = 'block'; } args.get_postBackElement().disabled = true; } </script> <div> <asp:UpdatePanel ID="PnlUsrDetails" runat="server"> <ContentTemplate> <table> <tr> <td> UserName: </td> <td> <asp:TextBox ID="txtUsername" runat="server" AutoPostBack="true"ontextchanged="txtUsername_TextChanged"/> </td> <td> <div id="checkusername" runat="server" Visible="false"> <asp:Image ID="imgstatus" runat="server" Width="17px" Height="17px"/> <asp:Label ID="lblStatus" runat="server"></asp:Label> </div> </td> </tr> </table> <div class="divwaiting " id="loadingdiv" style="display:none; margin-left:5.3em"> <img src="LoadingImage.gif" alt="Loading" />Please wait... </div> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html>
protected void txtUsername_TextChanged(object sender, EventArgs e) { if(!string.IsNullOrEmpty(txtUsername.Text)) { SqlConnection con = new SqlConnection("Data Source=manvendra;IntegratedSecurity=true;Initial Catalog=erp"); con.Open(); SqlCommand cmd = new SqlCommand("select * from tbl_admin where UserName=@UserName", con); cmd.Parameters.AddWithValue("@UserName", txtUsername.Text); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { checkusername.Visible = true; imgstatus.ImageUrl = "NotAvailable.jpg"; lblStatus.Text = "UserName Already Taken"; System.Threading.Thread.Sleep(2000); } else { checkusername.Visible = true; imgstatus.ImageUrl = "Icon_Available.gif"; lblStatus.Text = "UserName Available"; System.Threading.Thread.Sleep(2000); } } else { checkusername.Visible = false; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)