Click here to Skip to main content
15,908,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi iam developing an 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

after 30second the label should go what i should do
Updated 20-Feb-12 2:13am

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.
Share this answer
ashok_89 20-Feb-12 9:06am    
pls say how to make it in java script i searched and implemented nothing works help me sir
Dave Kreskowiak 20-Feb-12 10:54am    
I can't as I haven't done javascript or an ASP.NET app is years. I don't have an example, but if you Google "javascript timer" you can come up with examples quite easily.
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){
 var t=setTimeout("showLabel("+id+")",30000);
function hideLabel(id) {
document.getElementById(id).style.display = "none";
function showLabel(id) {
document.getElementById(id).style.display = "block";

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.


Share this answer
ashok_89 20-Feb-12 10:58am    
it hides sir but i need it to be hidden only for about 30 seconds and i need the script to be called from code behind button event, help me out sir
The Zetta 20-Feb-12 11:02am    
about calling script from code behind, you must set onclick event.
I'm improving the answer, check it in a moment.
ashok_89 20-Feb-12 11:47am    
ya sir but in codebehind also i have an on click event under that only i need to call the javascript function .
The Zetta 20-Feb-12 11:50am    
what do you mean? I think examples are clear enough.
Ariel Riyo 20-Feb-12 19:05pm    
maybe onload?
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
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900