Timer in asp.net

M

Mr Red

Hi all,

I have one label and one button. When I click the button
the label shows "Hello world". What I want to do is after
5 second the hello world is clear. How to do it with
asp.net. Im using vb.net as the languages.

Thanks
 
G

Guest

Hello there,

I try to use the code, I already add the javascript code
inside my asp.net but I have a problem when I call the
function. This is my code

<asp:Button id="btnUpdate" runat="server" Text="Update"
OnClick="startClock()"></asp:Button>

the error message pointer at OnClick="startClock()":
'startClock' is not a member of 'ASP.USER_aspx'.

any idea?

Thanks
 
M

Mark Rae

the error message pointer at OnClick="startClock()":
'startClock' is not a member of 'ASP.USER_aspx'.

That's correct. You've defined a web control and told it to run a procedure
called startClock() when it's clicked. Because of the runat=server, the page
will post back and try to run a server-side procedure called startClock().
You need to:

1) Create a client-side Javascript function called startClock()

2) Change the web control button to a regular HTML control: <input
type=button id=btnUpdate value=Update onClick="startClock();"> control.
Rendering it as a web control won't give you any advantage in this case
because you don't need it to interact with the server when it's clicked
 
M

Mr Red

Is there any possibility that Im using button from
asp.net rather then from the html? or maybe I can call
the function from code behine?

Thanks
 
P

Patrice

On the web, the page just lives the time of the request. It will be much
more easy to have a client side timer. Plus if you want to hide the button
server side you'll have also an extra request to the server.

ASP.NET does quite a good job to mimic usual event based programming but IMO
it's worth to know what goes under the hood...

Patrice
 
E

Eliyahu Goldin

Yes, you can keep asp.net button. You just need to add client side onclick
attribute like this (C# syntax):

btnUpdate.Attributes["onclick"']="startClock()";

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top