Javascript

Discussion in 'ASP .Net Web Controls' started by Timothy Elvidge, Jul 16, 2004.

  1. I have moved the following to the parent page for the menu control and I still can't see the Javascript appearing. This is what I am doing:-
    protected override void OnPreRender (System.EventArgs e)
    {
    Page.RegisterClientScriptBlock ("menuscript", "<script language=\"javascript\" src=\"default.js\"></script>\n");
    }
    I can use the ControlAt and write the script block as a literal control but would like to do this the right way.
    Timothy Elvidge, Jul 16, 2004
    #1
    1. Advertising

  2. Timothy Elvidge

    Dale Guest

    Move your code out of the control's OnPreRender and into the Page_Load event
    handler.

    But in this case, why not just hardcode the script block HTML into the ASPX
    page? You're using server resources here to generate something that is
    always the same and always known ahead of time. The server processing isn't
    adding anything at all to the final outcome.

    Dale



    "Timothy Elvidge" <> wrote in
    message news:D...
    > I have moved the following to the parent page for the menu control and I

    still can't see the Javascript appearing. This is what I am doing:-
    > protected override void OnPreRender (System.EventArgs e)
    > {
    > Page.RegisterClientScriptBlock ("menuscript", "<script

    language=\"javascript\" src=\"default.js\"></script>\n");
    > }
    > I can use the ControlAt and write the script block as a literal control

    but would like to do this the right way.
    Dale, Jul 16, 2004
    #2
    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. mcdeveloper
    Replies:
    1
    Views:
    4,161
    mcdeveloper
    Jun 13, 2006
  2. CRON
    Replies:
    24
    Views:
    200,238
    Adrienne Boswell
    Jun 20, 2006
  3. Mark Rae

    JavaScript or not JavaScript

    Mark Rae, Sep 5, 2006, in forum: ASP .Net
    Replies:
    36
    Views:
    1,045
    Paul Sture
    Sep 9, 2006
  4. Nathan Sokalski
    Replies:
    4
    Views:
    554
    PJ on Development
    Nov 8, 2007
  5. Lisa Calla
    Replies:
    0
    Views:
    253
    Lisa Calla
    Nov 9, 2004
Loading...

Share This Page