.CS File:
string TempstrStockId = ((TextBox)gvStockShifting. Rows[gvStkShiftrow.RowIndex]. FindControl("txtStockId")). Text.Trim();
string regexExp = @"^[0-9]+$";
Regex regexValid = new Regex(regexExp);
if (regexValid.IsMatch( TempstrStockId))
{
strStockId = TempstrStockId;
}else{
ScriptManager. RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
((TextBox)gvStockShifting. Rows[gvStkShiftrow.RowIndex]. FindControl("txtStockId")). Focus();
return;
}
ASPX File:
<script type="text/javascript">
function Showalert() {
alert('Call JavaScript function from codebehind');
}
</script>
No comments:
Post a Comment