ASP.NET标签使用JavaScript的变化知名度 [英] Change visibility of ASP.NET label with JavaScript

查看:159
本文介绍了ASP.NET标签使用JavaScript的变化知名度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp一个ASP.NET页面:按钮是不可见的。我不能把它用JavaScript可见的,因为它没有呈现到页面。

I have a ASP.NET page with an asp:button that is not visible. I can't turn it visible with JavaScript because it is not rendered to the page.

我能做些什么来解决这个?

What can I do to resolve this?

推荐答案

如果你需要操纵它在客户端,你不能在服务器端使用Visible属性。相反,设置它的CSS显示样式为无。例如:

If you need to manipulate it on the client side, you can't use the Visible property on the server side. Instead, set its CSS display style to "none". For example:

<asp:Label runat="server" id="Label1" style="display: none;" />

然后,你可以把它放在与客户端可见的:

Then, you could make it visible on the client side with:

document.getElementById('Label1').style.display = 'inherit';

您可以把它与重新隐藏起来:

You could make it hidden again with:

document.getElementById('Label1').style.display = 'none';

请,有可能是与客户端ID是在实践中比Label1的更为复杂的问题。你需要使用带的getElementById,而不是服务器端ID ClientID的,如果他们有所不同。

Keep in mind that there may be issues with the ClientID being more complex than "Label1" in practice. You'll need to use the ClientID with getElementById, not the server side ID, if they differ.

这篇关于ASP.NET标签使用JavaScript的变化知名度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆