.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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
nishant ranjanPosted Dec 22, 2011, 7:27 AM
and comment protected int cv_login_validate()
Pravin GhadgePosted Dec 22, 2011, 6:56 AM
can u attach that page.
nishant ranjanPosted Dec 22, 2011, 6:16 AM
nishant ranjanPosted Dec 22, 2011, 6:01 AM
Pravin GhadgePosted Dec 22, 2011, 5:50 AM
Is ur thread has been resolved.
Pravin GhadgePosted Dec 22, 2011, 3:23 AM
On Save button click event u have to use.
Page.Validate("add");
if(Page.IsValid)
{
.......
}
nishant ranjanPosted Dec 22, 2011, 3:08 AM
{
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 GhadgePosted Dec 22, 2011, 2:58 AM
Show me ur btn_save_Click code.
nishant ranjanPosted Dec 22, 2011, 2:52 AM
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 GhadgePosted Dec 22, 2011, 2:31 AM
Can u provide me ur code sniffet.