Check the Username Available During Progress Bar Show Using Javascript in Asp.Net C#

Check the Username Available During Progress Bar Show Using Javascript


Username Enter The Textbox Check Available Show Progress Bar Open PArticular Interval Time Using Javascript in Asp.Net C#. 

Username Check Without ProgressBar

                                DEMO



                    Download Coding
                         
                                       Download


                      HTML CODING


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>      
     <script type="text/javascript">      
         var Time = 03, check = null;
         var Time1 = 03, check1 = null;
         function ExistUser()
         {          
             check = setInterval(starttimer, 1000);
         }
         function AvailUser()
         {
             check1 = setInterval(endTimer, 1000);
         }       
         function starttimer()
         {
             Time -= 1;
           
             if (Time <= 0)
             {
                 clearInterval(check);
                 check = null;
                 Time = 0;

                 document.getElementById('<%=Image1.ClientID%>').style.display = "none";
                 var lbl1 = document.getElementById('<%=Label1.ClientID%>');
                 lbl1.innerText = "Already Exists";               
              
             }                      
         }               
         function endTimer()
         {
             Time1 -= 1;

             if (Time1 <= 0)
             {
                 clearInterval(check1);
                 check1 = null;
                 Time1 = 0;

                 document.getElementById('<%=Image1.ClientID%>').style.display = "none";
                 var lbl1 = document.getElementById('<%=Label1.ClientID%>');
                 lbl1.innerText = "Available Username";              
           }
       }
       </script>        
    </head>
<body>
    <form id="form1" runat="server">
    <div>         
             
        <table><tr><td>
     <asp:Label ID="Label2" runat="server" Text="Username"></asp:Label>
            </td><td>
        <asp:TextBox ID="txtUsername" runat="server" AutoPostBack="True"

            OnTextChanged="txtUsername_TextChanged" ></asp:TextBox>       
                        </td><td>     
      
                        <asp:Label ID="Label1" runat="server" ForeColor="#CC3300" ></asp:Label>
            </td></tr>
            <tr><td class="auto-style1"></td><td class="auto-style1">
        <asp:Image ID="Image1" runat="server" Width="123px" Height="183px" Visible="False" />
                </td></tr>
        </table>  
           </div>       
    </form>
</body>

</html>


                                 C# CODING



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Default6 : System.Web.UI.Page
{
    SqlConnection con;
    SqlCommand cmd;
    SqlDataAdapter adp;
    SqlDataReader rd;
    string query;


    public void dbcon()
    {
        string connn = (System.Configuration.ConfigurationManager.ConnectionStrings["dbcon"].ToString());
        con = new SqlConnection(connn);
        con.Open();

    }
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
  
    protected void txtUsername_TextChanged(object sender, EventArgs e)
    {
        dbcon();
        query = "select username from register";
        cmd = new SqlCommand(query, con);
        rd = cmd.ExecuteReader();
        while (rd.Read())
        {
            Label1.Text = "";         
            if (rd["username"].ToString() == txtUsername.Text.ToString())
            {        
                Image1.Visible = true;
                Image1.ImageUrl = "Progress1.gif";
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "ExistUser();", true);
                break;
            }
        else           
                {                    
                    Image1.Visible = true;
                    Image1.ImageUrl = "Progress.gif";
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script1", "AvailUser();", true);
                
                }          
           
        }
    }
     

}



First - Create New Web Form - Select Textbox,Image From ToolBox - Image visible=False





Next - Add JavaScript Function  For Intervel Set Image Display   After Show  Textbox Message="Already Exists"






Next - Add JavaScript Function  For Intervel Set Image Display   After Show  Textbox Message="Available Username"






Next - Double Click - TextBox - Add Coding For Username Check - if Available Call Javascript Available Interval or Else Part Work.







0 comments:

Post a Comment