Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
we can attach javascript in code behind using this style
private
{
System.Text.StringBuilder StrValidation =
StrValidation.AppendFormat(
function validateForm()
if (isBlank(document.baseForm.txtEmail.value)) {
alert('Email ID can not be blank1 !');
document.baseForm.txtEmail.focus();
return false;
}
if (isBlank(document.baseForm.txtSubject.value)) {
alert('Subject can not be blank !');
document.baseForm.txtSubject.focus();
if (isBlank(document.baseForm.txtMessage.value)) {
alert('Please Enter Message in Message Box !');
document.baseForm.txtMessage.focus();
return true;
} </script>"
Page.RegisterClientScriptBlock(