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
 
D

Dimitri Glazkov

Ronen,

I don't it is possible to emit markup from a control directly into the HEAD
element of the page. Your alternatives are either hard-coding these lines
into the page or coming up with a send/receive solution that would involve a
control, located in HEAD element. That control will be your receiver and the
grid will be the sender.

:DG<
 
B

bruce barker

..net does not directly support this, and you are stuck if the page does not
have a <head> section. if it does, scan the Page.Controls collection of
objects before the form object, check the generice html controls innerhtml
of the control for the <head> statement or (if user added a runat=server on
the head> a control with is tag), then update the inner html with your code
(if it is not already there).

-- bruce (sqlwork.com)


| 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
|
|
|
|
|
 

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

Top