I have 3 text box's and a submit button when i enter the va开发者_Python百科lues and submit then values are entered in database .
but when i enter the same values and enter then those values are also entered.......This should not happen...I need a popup window showing there are duplicate values that you have entered.Please give the code for aspx and aspx.cs and data base. Please explain in breif
try
{
int result = Timesheet_BI.InsertCompanyInformation(txtCompanyName.Text, txtAddress.Text);
if (result == -1)
{
txtCompanyName.Focus();
txtCompanyName.Attributes["onfocus"] = "this.select();";
string jv = "<script>alert('Error Details: Duplicate Entry of Company Name ');</script>";
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", jv, false);
return;
//Page.ClientScript.RegisterStartupScript(typeof(string), "My Script", "Duplicate Enteries");
}
}
catch (Exception ex)
{
throw ex;
}
Why don;t you use a simple java script to check this. or use JQuery /getElementById to get the controls and do a simple comparison.
If you have a bunch of textboxes to compage, give something similar to all the textbox Eg Give a common prefix to all textbox controls and use JQuery to get all the textboxes starting with that prefix and do a regular comparison. http://api.jquery.com/attribute-contains-selector/#
Eg;
$(:contains(<prefix>,textbox').each
(
function()
{
// do the comparison
}
)
精彩评论