Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > RegisterStartupScript not executing script

Reply
Thread Tools

RegisterStartupScript not executing script

 
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      10-05-2004

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


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      10-05-2004
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)


"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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
>
>



 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      10-05-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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
>
>



 
Reply With Quote
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      10-05-2004

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" wrote:

> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >
> > 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
> >
> >

>
>
>

 
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
script block added by the RegisterStartupScript zhuang ASP .Net 0 10-26-2006 01:06 PM
remove a script registered with RegisterStartupScript =?Utf-8?B?QWhtZWQ=?= ASP .Net 6 07-18-2006 06:50 PM
RegisterStartupScript not creating a <SCRIPT> block =?Utf-8?B?QWxleCBNYWdoZW4=?= ASP .Net 4 04-30-2006 10:29 PM
Problem in executing a script on the server side ! Script found but nothing executed ! CÚdric RossÚ ASP .Net 1 11-09-2004 09:43 AM
Re: client side script with RegisterStartupScript issue bruce barker ASP .Net 1 07-31-2003 08:39 PM



Advertisments