如何使标签不可见 [英] how to make the label invisible

查看:95
本文介绍了如何使标签不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在开发Vb.net Web应用程序,我有一个label1

在30秒后的页面加载中,我需要隐藏标签,这是怎么可能的.
我用了计时器

hi iam developing an Vb.net webapplication , i have an label1

at the pageload after a 30 seconds i need to hide the label how is it possible.
i used the timer

Dim Timer1 As New Timer()

Timer1.Interval = 2000

Timer1.Enabled = True


30秒后,标签应执行我应该执行的操作.


after 30second the label should go what i should do

推荐答案

您必须通过HTML中的脚本来执行此操作. ASP.NET代码完全在服务器端运行.这意味着一旦发送完客户端页面,它绝对无法控制客户端页面,因此您的计时器将永远无法工作.
You have to do this via script in the HTML. ASP.NET code runs ENTIRELY server-side. That means that is has absolutely no control over the client page once it''s finished being sent, so your timer will never work.



首先,要知道ASP.NET标签标记将呈现为html div或span.
其次,您不需要在后面的代码中设置计时器.只需使用输入或锚点或其他任何内容触发javascript.

试试这个:

Hi
First, know that ASP.NET label tag will be rendered as an html div or span.
Second, you dont need to setup a timer in your code behind. just trigger a javascript with either an input or an anchor or anything else.

Try this :

<input type="submit"  önclick="flick(yourlabelid);" value="hello" />
<a href="javascript:flick(yourlabelid); return false;">hello</a>
<div id="yourlabelid">content</div>


<script type="text/javascript">
function flick(id){
 hideLabel(id);
 var t=setTimeout("showLabel("+id+")",30000);
}
function hideLabel(id) {
document.getElementById(id).style.display = "none";
}
function showLabel(id) {
document.getElementById(id).style.display = "block";
}
</script>



在此示例中,输入和锚点均启动名为flick的javascript函数.此功能将隐藏渲染的标签,等待30秒,然后再次显示标签.

-----------------------
问候

H.Maadani



in this example both input and anchor launch javascript function named flick. this function hides rendered label, waits 30 seconds and shows the label again.

-----------------------
Regards

H.Maadani


也许您可以使用服务器端编码.建议您为计时器创建一个隐藏字段,例如,分配了label2来对计时器进行计数,但该字段被隐藏了,用户看不到它.

maybe you can use server side coding. is suggest you make a hidden field for the timer for example label2 is assigned to count the timer but it is hidden and the user cannot see it.

 if label1.text = "30" then
label1.visible = false
end if


这篇关于如何使标签不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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