asp net如何让后台代码控制div层显示及隐藏
前台JS
<style type="text/css">
* {margin:0;padding:0;font-size:12px;}
html,body {height:100%;width:100%;}
#content {background:#f8f8f8;padding:30px;height:100%;}
#content a {font-size:30px;color:#369;font-weight:700;}
#alert {border:1px solid #369;width:260px;height:90px;background:#e2ecf5;z-index:1000;position:absolute;display:none;}
#alert h4 {height:20px;background:#369;color:#fff;padding:5px 0 0 5px;}
#alert h4 span {float:left;}
#alert h4 span#close {margin-left:210px;font-weight:500;cursor:pointer;}
#alert p {padding:12px 0 0 30px;}
#alert p input {width:120px;margin-left:20px;}
#alert p input.myinp {border:1px solid #ccc;height:16px;}
#alert p input.sub {width:60px;margin-left:30px;}
</style>
<div id="alert" style="text-align:center " >
<h4><span>系统提示</span></h4>
<table>
<tr>
<td colspan="3" style="height:14px"></td>
</tr>
<tr>
<td style="width:10%"></td>
<td style="text-align:right"> <img alt="a" src="../Image/13221820.gif" /></td>
<td style="text-align:left">短信正在发送中,请不要关闭网页! </td>
</tr>
</table>
</div>
<script type="text/ecmascript">
var myAlert = document.getElementById("alert");
function show() {
myAlert.style.display = "block";
myAlert.style.position = "absolute";
myAlert.style.top = "50%";
myAlert.style.left = "50%";
myAlert.style.marginTop = "-75px";
myAlert.style.marginLeft = "-150px";
document.body.style.overflow = "hidden";
}
</script>
<script type="text/javascript">
function close() {
myAlert.style.display = "none";
}
</script>
后台按钮事件中的代码:
if (TextBox1.Text.Trim() == "" || TextBox2.Text.Trim() == "")
{
Page.RegisterStartupScript("f","<script>alert('不能为空');</script>");
return;
}
Page.RegisterStartupScript("", "<script> show() ;</script>");//正常弹出
// Page.RegisterStartupScript("show", "<script> show() ;</script>"); 当key不为空字符串的时候,DIV不能弹出
for (int i = 0; i < 10000; i++)
{
if (i == 9999)
{
Page.RegisterStartupScript("", "<script>close();</script>");//DIV不能隐藏
//Page.RegisterStartupScript("close", "<script>close();</script>");DIV不能正常弹出
Page.RegisterStartupScript("d", "<script>alert('ok');</script>");