问题描述
我有一个asp网站有以下控制:
I have an asp website with the following control:
<span id="expTrainingShow" class="clsLink" style="margin-left: 20px;" onclick="GridChanger();">
+ Show Expired Continuing Education</span>
我想基于code后面设置一个条件隐藏此。我可以访问的跨度ID喜欢吗? (网站使用Visual Basic中内置)
I want to hide this based on a condition set in the code behind. Can I access a span id like that? (the website is built using visual basic)
推荐答案
您可以使用标签
代替HTML跨度(也呈现为跨度)或您可以添加 =服务器
。
You can use a Label
instead of a html-span (which is also rendered as span) or you could add runat="server"
.
<span id="expTrainingShow" runat="server" class="clsLink" style="margin-left: 20px;" onclick="GridChanger();" ></span>
在codebehind(跨度是<$c$c>HtmlGenericControl$c$c>在服务器端):
somewhere in codebehind(the span is a HtmlGenericControl
on serverside):
expTrainingShow.InnerHtml = yourText ' set the text '
或
expTrainingShow.Visible = False ' hide it '
注意可见=假
在服务器端意味着控制不呈现在所有的客户方,因此它不会在HTML中存在,并且可以在服务器端只访问
Note that Visible=False
on serverside means that the control is not rendered at all on clientside, hence it does not exist in the html and can be accessed only on serverside.
如果你只想隐藏它,但无论如何呈现它,你应该使用CSS或 expTrainingShow.Style.Add(显示,无)
。
If you just want to hide it but render it anyway, you should use CSS or expTrainingShow.Style.Add("display","none")
.
这篇关于如何访问跨度ID在code背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!