cs:
写在Page_Load 里面
Button1.Attributes.Add("onclick", "return fun(" + TextBox1.ClientID + "," + TextBox2.ClientID + ");");
aspx:
<script language ="javascript">
function fun(tname,tpwd)
{
if(tname.value=="")
{
alert("请输入用户名!");
return false;
}
if(tpwd.value=="")
{
alert("请输入密码!");
return false;
}
}
</script>