use*_*156 5 javascript c# asp.net
我在我的Page_Load上注册了这个
Page.ClientScript.RegisterStartupScript(this.GetType(), "clientscript", "document.getElementById('showdiv').style.visibility = 'hidden';", true);
Run Code Online (Sandbox Code Playgroud)
但它没有被隐藏......我的div如下所示
<div id="showdiv">
<input class="button" type="button" value="OK" name="success_button" id="my button" onclick="javascript:window.close();" />
</div>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?.谢谢您的帮助
我强烈建议使用JavaScript进行这种简单的客户端操作(show/hode行控件等),或者更容易使用jQuery这样的.js库.在应用程序中包含jQuery脚本之后,只需在页面完成初始化后隐藏该DIV即可.
如果您已经有一个脚本部分,请将此脚本部分包含在页面顶部或引用的.js文件中:
<script type="text/javascript">
//$(document).ready is used to define a function that is guaranteed to be called only after the DOM has been initialized.
$(document).ready(function () {
//Hide the div
$('#showdiv').hide();
//conversely do the following to show it again if needed later
//$('#showdiv').show();
});
</script>
Run Code Online (Sandbox Code Playgroud)
有关此方法的jQuery API文档:http:
//api.jquery.com/hide/