RegisterStartupScript not executing script

G

Guest

Hi,

I am trying to resize a HTML table through Javascript. When the user control
loads the first time, the table is resized, but then it doesn't anymore. I am
using the following code in the Load event of the web user control:

if ( [expression] )
this.Page.RegisterStartupScript("CallBothGrids", "<script
language=javascript> { showBothGrids(); }</script>");
else
this.Page.RegisterStartupScript("CallFundsOnly", "<script
language=javascript> { showFundsOnly(); }</script>");

The "CallFundsOnly is executed (the first time), but the "CallBothGrids" is
not. I don't see any error message when the page is rendered in Internet
Explorer.
Any idea of what could be wrong?

Thanks.
Mike
 
B

bruce barker

RegisterStartupScript renders the javascript just before the </form>, thus
your javascript is executing before the page has been fully rendered (or
even fully parsed). if your resize logic is using calculated values, they
may be zero at this time. move you resize logic to the body onload event,
which will fire after the page has rendered by the browser, and content has
been sized..


-- bruce (sqlwork.com)
 
K

Karl Seguin

There's nothing wrong with what you've shown us.

The possibilities are an error in your javascript or simply your if
expression is never evaluating to true.

Try replacing showBothGrids(); with alert('test'); and see if that works

Karl
 
G

Guest

Karl,

I have already tried with "alert" but nothing is shown. I also used
breakpoints, and I am sure that the line of code is executed.

The postback is caused by a javascript refresh. I wonder whether this could
be the problem.

Mike


Karl Seguin said:
There's nothing wrong with what you've shown us.

The possibilities are an error in your javascript or simply your if
expression is never evaluating to true.

Try replacing showBothGrids(); with alert('test'); and see if that works

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


Mike said:
Hi,

I am trying to resize a HTML table through Javascript. When the user control
loads the first time, the table is resized, but then it doesn't anymore. I am
using the following code in the Load event of the web user control:

if ( [expression] )
this.Page.RegisterStartupScript("CallBothGrids", "<script
language=javascript> { showBothGrids(); }</script>");
else
this.Page.RegisterStartupScript("CallFundsOnly", "<script
language=javascript> { showFundsOnly(); }</script>");

The "CallFundsOnly is executed (the first time), but the "CallBothGrids" is
not. I don't see any error message when the page is rendered in Internet
Explorer.
Any idea of what could be wrong?

Thanks.
Mike
 

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,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top