.aspx
.cs
protected void cv_login_validate(object sender, ServerValidateEventArgs e)
{
............
........
if (temp > 0)
{
e.IsValid = false;
}
else
{
e.IsValid = true;
}
}
button code
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 21, 2011, 9:31 PM EST
Can u provide me ur code sniffet.
nishant ranjanRank #4,961 · 317 reputationPosted Dec 21, 2011, 9:52 PM EST
in cs part
protected void cv_login_validate(object sender, ServerValidateEventArgs e)
{
int temp = 0;
con.Close();
string qry = string.Format("select count(*) from login_detail where loginname='{0}'", (txt_username.Text));
cmd = new SqlCommand(qry, con);
con.Open();
temp = Convert.ToInt32(cmd.ExecuteScalar());
if (temp > 0)
{
e.IsValid = false;
}
else
{
e.IsValid = true;
}
}
in aspx page
on button click
asp:Button ID="btn_save" runat="server" Font-Bold="true" Text="Save"
onclick="btn_save_Click" ValidationGroup="add" style="height: 26px" CausesValidation="true"/>
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 21, 2011, 9:58 PM EST
Show me ur btn_save_Click code.
nishant ranjanRank #4,961 · 317 reputationPosted Dec 21, 2011, 10:08 PM EST
{
string pwd = txt_patpass.Text;
string re_pwd = txt_repatpass.Text;
string password = Encrypt(pwd);
string re_password = Encrypt(re_pwd);
login_name = txt_username.Text.ToLower();
try
{
if (password == re_password)
{
con.Close();
cmd = new SqlCommand("select id from login_detail where loginname='" + txt_pname.Text + "'", con);
con.Open();
SqlDataReader rd = cmd.ExecuteReader();
rd.Read();
if (!rd.HasRows)
{
con.Close();
cmd = new SqlCommand("select value from main_master where description='patient'", con);
con.Open();
string roleid = cmd.ExecuteScalar().ToString();
con.Close();
cmd = new SqlCommand("proc_patient_detail", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@login_name", login_name);
cmd.Parameters.AddWithValue("@password", password);
cmd.Parameters.AddWithValue("@roleid", roleid);
cmd.Parameters.AddWithValue("@user_sts", 1);
cmd.Parameters.AddWithValue("@login_sts", 0);
cmd.Parameters.AddWithValue("@patient_name", txt_pname.Text);
cmd.Parameters.AddWithValue("@address", txt_paddress.Text);
cmd.Parameters.AddWithValue("@mobile_no", txt_pmobile.Text);
cmd.Parameters.AddWithValue("@emailid", txt_pemail.Text);
cmd.Parameters.AddWithValue("@streamid", login_name);
cmd.Parameters.AddWithValue("@amount", txt_amount.Text);
con.Close();
con.Open();
cmd.ExecuteNonQuery();
con.Close();
sendmail();
ClientScript.RegisterClientScriptBlock(this.GetType(), "success", "alert('Submitted Successfully');window.location.href='editpatient.aspx';", true);
//Response.Redirect("addpatient.aspx");
}
else
{
lbl_loginmsg.Text = "User Already Exist";
lbl_loginmsg.Visible = true;
}
}
}
catch (Exception ex)
{
}
}
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 21, 2011, 10:23 PM EST
On Save button click event u have to use.
Page.Validate("add");
if(Page.IsValid)
{
.......
}
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 22, 2011, 12:50 AM EST
Is ur thread has been resolved.
nishant ranjanRank #4,961 · 317 reputationPosted Dec 22, 2011, 1:01 AM EST
nishant ranjanRank #4,961 · 317 reputationPosted Dec 22, 2011, 1:16 AM EST
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 22, 2011, 1:56 AM EST
can u attach that page.
nishant ranjanRank #4,961 · 317 reputationPosted Dec 22, 2011, 2:27 AM EST
and comment protected int cv_login_validate()