如何访问跨度ID在code背后 [英] How to access span id in code behind

查看:151
本文介绍了如何访问跨度ID在code背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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(跨度是<一个地方href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlgenericcontrol.aspx\"><$c$c>HtmlGenericControl在服务器端):

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背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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