RegisterStartupScript not executing script

Discussion in 'ASP .Net' started by =?Utf-8?B?TWlrZQ==?=, Oct 5, 2004.

  1. 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
     
    =?Utf-8?B?TWlrZQ==?=, Oct 5, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?TWlrZQ==?=

    bruce barker Guest

    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" <> wrote in message
    news:...
    >
    > 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
    >
    >
     
    bruce barker, Oct 5, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?TWlrZQ==?=

    Karl Seguin Guest

    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" <> wrote in message
    news:...
    >
    > 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
    >
    >
     
    Karl Seguin, Oct 5, 2004
    #3
  4. 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" <> wrote in message
    > news:...
    > >
    > > 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
    > >
    > >

    >
    >
    >
     
    =?Utf-8?B?TWlrZQ==?=, Oct 5, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bruce barker
    Replies:
    1
    Views:
    528
    Dave Stienessen
    Jul 31, 2003
  2. Marshal Antony
    Replies:
    2
    Views:
    655
    Marshal Antony
    Dec 1, 2004
  3. =?Utf-8?B?QWhtZWQ=?=

    remove a script registered with RegisterStartupScript

    =?Utf-8?B?QWhtZWQ=?=, Jun 13, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    9,002
  4. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    RegisterStartupScript not creating a <SCRIPT> block

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Apr 30, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    4,346
    =?Utf-8?B?QWxleCBNYWdoZW4=?=
    Apr 30, 2006
  5. zhuang
    Replies:
    0
    Views:
    382
    zhuang
    Oct 26, 2006
Loading...

Share This Page