小台的IT备忘录  
脑子越来越不好用,只能依靠烂笔头了~

方法一:此方法应该是微软官方推荐的方法,但弹出时会造成页面白屏。
Page.RegisterStartupScript("TestEvent", "<script>alert('所属部门不能为空!');</script>");
这个方法用于在页响应中发出客户端脚本块,前一个参数是该Script在页面中的唯一名称(随便起,不重复就行),后一个是脚本内容。

方法二:此方法有时候会在成页面模型混乱,造成字体变大没有样式。
Response.Write("<script>alert('所属部门不能为空!');indow.location='MemberList.aspx';</script>");
Response.Write("<script>alert('所属部门不能为空!');document.location=document.location;</script>");

 

方法三:此方法弹出文本框不会造成后面白屏,也不会再成字体变大等样式错误。

Page.RegisterStartupScript("<script>alert('所属部门不能为空!');</script>");

posted on 2016-06-21 16:15  taiyonghai  阅读(678)  评论(0编辑  收藏  举报