How to set check availability button in registration form using aspnet
First,open the visual studio 2008
Next,select one Asp Web Application and click ok
Next download one Gif image for to show loading
Next,Open the design page of Default.aspx
Next,Drag and drop one UpdatePanel,one textbox from the toolbox
Next,In that Updatepanel Drag and drop one Link button and label
Next,add one image
Next,Come to the Source page of default.aspx page
Next,code will be look like this
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<div id="divImage" style="display:none">
<asp:Image ID="img1" runat="server" ImageUrl="~/images/ajax-loader.gif" />
Processing...
</div>
<br />
<asp:LinkButton ID="lb_checkavail" runat="server" CausesValidation="False"
Font-Underline="False" onClick="lb_checkavail_Click"
style="font-weight: 700" ForeColor="#00CCFF">Check Availability</asp:LinkButton><br />
<asp:Label ID="lbl_msg1" runat="server" Font-Bold="True"
Font-Names="Verdana" ForeColor="#FF9933"></asp:Label></ContentTemplate>
</asp:UpdatePanel>
Now,come to the code page of Default.aspx.cs
write the following code for the link button
protected void lb_checkavail_Click(object sender, EventArgs e)
{
con = new SqlConnection(ConfigurationManager.ConnectionStrings["SAMPLE_2"].ToString());
con.Open();
com = new SqlCommand("select * from Users where Username='"+txt_uname.Text+"'",con);
dr = com.ExecuteReader();
if (dr.Read())
{
lbl_msg1.Text = "Not Availble";
this.lbl_msg1.ForeColor = Color.DarkGreen;
}
else
{
if (txt_uname.Text == "")
{
lbl_msg1.Text = "Please Enter the Username";
}
else
{
lbl_msg1.Text = "Available";
}
}
}
Finally execute the page.....Thats it...
Labels: .Net Tutorials, Aspnet, C#, CSharp, Tanisha
5 Comments:
Hey its very simple..thanks
very useful tip
Thanks for sharing
Hey its very simple..thanks
great post
Post a Comment
Subscribe to Post Comments [Atom]
<< Home