服务器端验证
protected void Button1_Click(object sender, EventArgs e){
int cMid = 3;
String cAuthor, cContent, cHead, cEmail, cTime, cIp;
if (Session[ "uName "] != null)
cAuthor = Session[ "uName "].ToString();
else
cAuthor = " ";
这个地方要是cAuthor为空的时间,怎么停止提交,在客户端弹出提示
ClientScript.RegisterStartupScript(typeof(string), " ", " <script> alert( '留言过程中发生错误 ');location.href= 'MessageView.aspx; </script> ");这个不行
//cContent = TextBox2.Text;
cHead = "image/ima/dsa.jpg ";
//cEmail = TextBox3.Text;
cTime = DateTime.Now.ToString();//Now;
cIp = Request.ServerVariables[ "REMOTE_ADDR "];
String strSql = "insert into RestoreInfo (mId,rAuthor,rContent,rHaed,rEmail,rTime,rIp) values(@mId,@Author,@Content,@Head,@Email,@Time,@Ip) ";
SqlParameter [] parms = { new SqlParameter( "@mId ",SqlDbType.Int),
new SqlParameter( "@Author ",SqlDbType.VarChar,15),
new SqlParameter( "@Content ",SqlDbType.VarChar,8000),