Calling Javascript function

K

Krishna

Hi all,

Can i call my javascript functions from the web controls.Any appropriate
site which will be tell more on this will be helpfull.

Regards..,
Krishna
 
K

Kevin Spencer

JavaScript executes on the client side. It is sent to the client as
scripting embedded in the HTML of a page. Therefore, you cannot interact
directly with JavaScript on the server side. You CAN, however, add
JavaScript to a page on the server, which will execute when the page loads
in the browser. You can do this by using the
Page.RegisterClientScriptBlock() and Page.RegisterStartupScript() methods.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Some things just happen.
Everything else occurs.
 
P

pat sinnott

Hi

I don't actually think it is this complicated.

You call use Javascript with server side controls exactly
as you use it with normal clientside HTML controls. There
are however a few caveats.

If the name of a server side event clashes with the name
of the client side event this will lead to a problem.
So for instance if you are programming javascript against
a webform button control you will need to use the
onMousedown client side event rather than the onclick
event as the there is an event named onclick on the server
side.

You will have no intellisense when you write the
javascript code against the server side controls as these
controls do not actually exist till they are rendered as
HTML when the application executes.
Also when referencing the control reference it as
document.all rather than document.Form1, I have sometimes
had problems with the latter syntax.

Regards,

Pat Sinnott MCSD

-----Original Message-----
JavaScript executes on the client side. It is sent to the client as
scripting embedded in the HTML of a page. Therefore, you cannot interact
directly with JavaScript on the server side. You CAN, however, add
JavaScript to a page on the server, which will execute when the page loads
in the browser. You can do this by using the
Page.RegisterClientScriptBlock() and
Page.RegisterStartupScript() methods.
 

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
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top