Render Javascript into a WebControl.

R

Ronen

Hi,

I am writing a grid Web control library.

The grid has some client side JavaScript to enable columns resize, sorting,
row selection etc.



I have some problems adding the JavaScript link at the render of the
control:



1) During the render method of the control I need to add the following code:

<link type="text/css" rel="stylesheet" href="includes/WLGrid.css" />
<script type="text/javascript" src="includes/WLGridSort.js"></script>
<script type="text/javascript" src="includes/WLGridLib.js"></script>

I need this code to be rendered in the Head section of my page and NOT
in the control section.



2) In Case user put two controls on the page I want the JS code to appear
only once in the <Head> of the rendered HTML.



Thanks,

Ronen
 
T

Thiruppathi S

Hi Ronen,

Use Page.RegisterStartupScript command

If Not MyBase.Page Is Nothing AndAlso Not
MyBase.Page.IsStartupScriptRegistered("StartupScript") Then
MyBase.Page. RegisterStartupScript("StartupScript","<link
type='text/css' rel='stylesheet' href='includes/WLGrid.css'/>")
End If

Rgds,
Thiruppathi 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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top