I’m new in asp.net. and I’m am creating a simple Shoe Store Billing Management System. I want to know how to fire textbox validate event. Just like as we do in windows app textbox validate event. I have lost of shoes in my shoes table. And there is two column in table ShoseCode and ShoseDesc. When I enter the ShoseCode in ShoseCode Textbox and if this ShoseCode is already exist in ShoseCode Colum. So this ShoseCode information retrieve from database. Or if this cant retrieve so just show the message like “This Shoes Code already exist” or something like this.
Thanks in Advance J

Satyapriya NayakPosted Jun 12, 2014, 1:35 PM
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace WebApplication2
{
public partial class _Default : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
string str ;
public void ShoseCode_check()
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select count(*)from Shose where ShoseCode ='" + txt_ShoseCode.Text + "'";
com = new SqlCommand(str, con);
int count = Convert.ToInt32(com.ExecuteScalar());
if (count > 0)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Display('" + txt_ShoseCode.Text + "')", true);
lblMessage.Text = "This Shoes Code already exist";
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Display('" + txt_ShoseCode.Text + "')", true);
lblMessage.Text = "This Shoes Code does not exist";
}
}
protected void txt_ShoseCode_TextChanged(object sender, EventArgs e)
{
ShoseCode_check();
}
protected void Timer1_Tick(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}
}
}
Sunny ShaikhPosted Jun 13, 2014, 3:30 AM
Sunny ShaikhPosted Jun 12, 2014, 8:28 AM
Srikanth ReddyPosted Jun 12, 2014, 6:40 AM
for validation of textbox,we have two methods which i know
1)Code behind
2)Javascript
in code behind::
In textbox changed event,write the code for shoe code is avialable or not in the database.If you have the shoecode in database give an alert box.Thats enough.
in javascript::
we use ajax json method
if you have any doubts regarding this reply to me