导航

http://bbs.blueidea.com/thread-2887319-1-1.html

 

用DIV+CSS做网页,form表单一提交,页面就不居中了。比如说登录页面,挡用户名和密码舒服错误的时候,页面刷新弹出错误提示,确认后登录页面就变形了。

当页面不居中的时候,查看xhtml源代码(浏览器中的)。注意观察 <!DOCTYPE html PUBLIC "-/..... 声明之前是否有空白或其其它字符。一般是cs文件里response.write的后果。

查看源码,多了行代码:
<script>alert('密码修改成功!');</script>在<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">之前。

解决方法:

表单提交出错,弹出对话框用:Page.ClientScript.RegisterStartupScript(this.GetType(), null, "alert('密码修改成功!')", true); 

或者:

 if (ClientScript.IsStartupScriptRegistered("SuccessAlert"))
{
  this.ClientScript.RegisterStartupScript(this.GetType(), "SuccessAlert", alert('弹出提示'), true);