Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Writing single client script block for mutiple controls

Reply
Thread Tools

Writing single client script block for mutiple controls

 
 
Jason Barnett
Guest
Posts: n/a
 
      06-09-2006
I'm using .NET 1.1 and I've created a server control that writes javascript
to the output writer. The control works great, except when I add additional
controls. The problem is that each control writes the same javascript block,
which causes a stack overflow when it is executed.

Could someone tell me how I may write the javascript to the page only once,
regardless of how many controls are dropped on the web form?
 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      06-09-2006
In the RegisterClientScriptBlock method, what are you using as the key (the
first parameter)?
--
Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/

"Jason Barnett" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> I'm using .NET 1.1 and I've created a server control that writes
> javascript
> to the output writer. The control works great, except when I add
> additional
> controls. The problem is that each control writes the same javascript
> block,
> which causes a stack overflow when it is executed.
>
> Could someone tell me how I may write the javascript to the page only
> once,
> regardless of how many controls are dropped on the web form?



 
Reply With Quote
 
 
 
 
Jason Barnett
Guest
Posts: n/a
 
      06-09-2006
I'm not using the RegisterClientScriptBlock method. From what I've read,
that is a method on the ClientScriptManager class and is only available in
..NET 2 or higher. Is there something comparable in .NET 1.1?

I'm currently writing the script as plain text using output.Write method
within the Render method.


"Nathan Sokalski" wrote:

> In the RegisterClientScriptBlock method, what are you using as the key (the
> first parameter)?
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>
> "Jason Barnett" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
> > I'm using .NET 1.1 and I've created a server control that writes
> > javascript
> > to the output writer. The control works great, except when I add
> > additional
> > controls. The problem is that each control writes the same javascript
> > block,
> > which causes a stack overflow when it is executed.
> >
> > Could someone tell me how I may write the javascript to the page only
> > once,
> > regardless of how many controls are dropped on the web form?

>
>
>

 
Reply With Quote
 
Jason Barnett
Guest
Posts: n/a
 
      06-09-2006
Ok, I now see where I made one mistake. I did a search on
RegisterClientScriptBlock and found that it is a method on the Page class
(although, it does not appear in intellisense). I modified my code to use
the RegisterClientScriptBlock method in conjunction to the
IsClientScriptBlockRegistered method, but multiple blocks are still being
written to the page.

I'm using a constant as the key (ex: "MyClientScript").


"Jason Barnett" wrote:

> I'm not using the RegisterClientScriptBlock method. From what I've read,
> that is a method on the ClientScriptManager class and is only available in
> .NET 2 or higher. Is there something comparable in .NET 1.1?
>
> I'm currently writing the script as plain text using output.Write method
> within the Render method.
>
>
> "Nathan Sokalski" wrote:
>
> > In the RegisterClientScriptBlock method, what are you using as the key (the
> > first parameter)?
> > --
> > Nathan Sokalski
> > (E-Mail Removed)
> > http://www.nathansokalski.com/
> >
> > "Jason Barnett" <(E-Mail Removed)> wrote in message
> > news(E-Mail Removed)...
> > > I'm using .NET 1.1 and I've created a server control that writes
> > > javascript
> > > to the output writer. The control works great, except when I add
> > > additional
> > > controls. The problem is that each control writes the same javascript
> > > block,
> > > which causes a stack overflow when it is executed.
> > >
> > > Could someone tell me how I may write the javascript to the page only
> > > once,
> > > regardless of how many controls are dropped on the web form?

> >
> >
> >

 
Reply With Quote
 
Jason Barnett
Guest
Posts: n/a
 
      06-09-2006
I am starting to wonder if the problem lies within the script block itself...
here is an example of what I'd like written out only once. Does it matter
that it is linked to an external .js file?

<script src="javascrip/myControl.js" type="text/javascript"></script>


"Nathan Sokalski" wrote:

> In the RegisterClientScriptBlock method, what are you using as the key (the
> first parameter)?
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>
> "Jason Barnett" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
> > I'm using .NET 1.1 and I've created a server control that writes
> > javascript
> > to the output writer. The control works great, except when I add
> > additional
> > controls. The problem is that each control writes the same javascript
> > block,
> > which causes a stack overflow when it is executed.
> >
> > Could someone tell me how I may write the javascript to the page only
> > once,
> > regardless of how many controls are dropped on the web form?

>
>
>

 
Reply With Quote
 
Jason Barnett
Guest
Posts: n/a
 
      06-09-2006
Ok, I got it. I was trying to use the RegisterClientScriptBlock method
during the Render event. When I used it during the PreRender event it began
working.


"Jason Barnett" wrote:

> I am starting to wonder if the problem lies within the script block itself...
> here is an example of what I'd like written out only once. Does it matter
> that it is linked to an external .js file?
>
> <script src="javascrip/myControl.js" type="text/javascript"></script>
>
>
> "Nathan Sokalski" wrote:
>
> > In the RegisterClientScriptBlock method, what are you using as the key (the
> > first parameter)?
> > --
> > Nathan Sokalski
> > (E-Mail Removed)
> > http://www.nathansokalski.com/
> >
> > "Jason Barnett" <(E-Mail Removed)> wrote in message
> > news(E-Mail Removed)...
> > > I'm using .NET 1.1 and I've created a server control that writes
> > > javascript
> > > to the output writer. The control works great, except when I add
> > > additional
> > > controls. The problem is that each control writes the same javascript
> > > block,
> > > which causes a stack overflow when it is executed.
> > >
> > > Could someone tell me how I may write the javascript to the page only
> > > once,
> > > regardless of how many controls are dropped on the web form?

> >
> >
> >

 
Reply With Quote
 
sam
Guest
Posts: n/a
 
      06-17-2006
Watch out for this method. After 8 different calls it will start
outputing the script tags in a random order with respect to what order
the method executes in the page. this is because microsoft uses the
retarded HybridDictionary class.

Should'nt make a difference unless you require the script tags to be
output in a specific order.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mutiple JVM in Single Os Senthil Java 4 02-11-2007 04:49 PM
More than a single script block within a single HEAD and BODY Water Cooler v2 Javascript 2 04-18-2006 11:00 AM
Mutiple external IPs on single interface Kevin Coles Cisco 5 01-10-2006 04:46 PM
display mutiple rows data fields for single record Chris ASP .Net 1 04-29-2005 03:14 PM
Mutiple Instance of Single EXE - VC++ varadha C++ 3 09-09-2003 07:33 PM



Advertisments