Declare in page
<input type="hidden" id="confirmed" name="confirmed" value="">
Set up javascript validation
function SelectBtn_Click(src, e)
{
var f = document.MyForm;
var v = f.NumberOfTxt.value;
if (IsStringOfDigits(v) && confirm("Are you sure you want to select " + v + "?\n If \"Yes\" click OK, otherwise click Cancel."))
{
document.MyForm.confirmed.value = "Y";
event.returnValue = true;
return true;
}
else
{
document.MyForm.confirmed.value = "";
event.returnValue = false;
return false;
}
}
Set attribute in code behind
this.SelectBtn.Attributes["onclick"] = "return SelectBtn_Click(this, event);";
In postback, check the hidden value
"Y".Equals(Request.Form["confirmed"])
No comments:
Post a Comment