使非 asp 表在后台代码中不可见
我正在使用其他人编写的代码,目前我无法对其进行太多更改。
它在 html 中定义了一个表,如下所示:
<table id="tblResult">
some stuff defined in here.
</table>
我想使用后面的代码使该表及其所有内容不可见,但我注意到我无法在后面的代码中直接将该表寻址为 tblResult.visible 。这对我来说很有意义,因为这不是一个 asp 对象。简单地将其更改为 asp:table 是行不通的,因为该表内发生了一些事情,我不想弄乱。是否可以在后台代码中寻址该表并将可见性设置为 false?
I'm working with code someone else has written that I cannot change too much for now.
It has a table defined in the html, something like this:
<table id="tblResult">
some stuff defined in here.
</table>
I would like to use the behind code to make this table and all its contents invisible, but I notice I can't address the table directly as tblResult.visible in the code behind. This makes sense to me, since this is not an asp object. Simply changing this to an asp:table doesn't work, as there's some stuff going on inside that table I prefer not to mess with. Is it possible to address that table and set visibility to false from the behindcode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将
runat='server'
添加到标记中。您可以做的另一件事是将其包裹在 div、panel 等服务器端标记中,并将它们设置为visible='false'
达到此效果:然后在您的代码隐藏中:
this.myDiv.Visible=False;
现在这将确保您的表格不可见。同样,您可以使用 div、面板(实际上只是 div)、文字、占位符等。
Add
runat='server'
to the tag. The other thing you can do is wrap it around a server side tag of div, panel, etc and set them tovisible='false'
Something to this effect:Then in your code-behind:
this.myDiv.Visible=False;
This will now ensure your table is not visible. Again you can use div's, panels (which are just divs really), literals, placeholders, etc.
您可以将其包装在
Literal
中:You can wrap it in a
Literal
:将其包装到
amd 中,然后切换占位符可见性。Wrap it into a
<asp:PlaceHolder>
amd then toggle the placeholder visibility.