Including Java Scripts in Server controls

S

Sundararajan

Dear Folks,

I am developing a server control as a composite control. I need to
associate some javascripts with the individual controls of the composite
control.
I have the javascrips in a separate .js file. how can i associate the
functions in .js file with the server controls.

Thanx in advance

Regards,
 
K

Kannan.V [MCSD.net]

hi,

Add an include line to link the js file to your page,
This can be done using Page.Registerstartupscript("Key","Script")
Once the js file is linked with ur page, you can assign the methods in the
js file to the control events.
Ex: btnButton.Attributes.Add("OnClick", "YourJSfunction");

play around with this and you'll get to know a lot more...

Regds
Kannan.V
 
K

Kannan.V [MCSD.net]

hi,

Add an include line to link the js file to your page,
This can be done using Page.Registerstartupscript("Key","Script")
Once the js file is linked with ur page, you can assign the methods in the
js file to the control events.
Ex: btnButton.Attributes.Add("OnClick", "YourJSfunction");

play around with this and you'll get to know a lot more...

Regds
Kannan.V
 
B

Brock Allen

You want Page.RegisterClientScriptBlock to register a block of functions.
You'll need to add your own <script language=...> in your script (the 2nd
param to the method).
 
D

Dale Preston

In your server control, do something like:

Response.Write("<script src='" + myScriptFileUrl + "'></script>");

That will cause the browser to load the javascript file.

HTH

Dale Preston
MCAD, MCDBA, MCSE
 
S

Sundararajan

Hi,

however in this the registerstartupscript methog requires the script be
passed as string. but i have it a separate file and i want to refer to that
file by using the url. is that possible. or should i read from the url and
convert it into a string and then use this method.

regards,
sundararajan.s
 

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

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,733
Latest member
LonaMonzon

Latest Threads

Top