getElementById 提示'缺少对象'的问题 找不到原因 在线等
Repeater有一些信息页面Load时是收缩的 还有个LinkButton
<asp:Repeater ID= "Repeater " Runat= "server ">
<itemtemplate>
<table>
<tr id= "line001 " style= "DISPLAY:none; VISIBILITY:hidden "> </tr>
<asp:LinkButton ID= "LinkButtonSave " Runat= "server " CommandName= "Save " text= "确认 "> </asp:LinkButton>
</table>
</itemtemplate>
</asp:Repeater>
希望点Button时收缩起来的信息保持展开状态 但报错缺少对象
private void Repeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if(e.CommandName== "Save ")
{
Response.Write( " <script> alert( '更改成功 ') </script> ");
Response.Write( " <script> window.document.getElementById( 'line001 ').style.display = 'block '; </script> ");
Response.Write( " <script> window.document.getElementById( 'line001 ').style.visibility = 'visible '; </script> ");
}
}
[解决办法]
呵呵,有可能是网页没有加载完毕的结果。试一下Page.RegisterStartupScript(JS)
[解决办法]
用 this.Page.RegisterStartupScriptResponse.Write 的脚本会在页面的顶端,些时文档没有加载。