Register javascript block globally...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cliff Harris

    Register javascript block globally...

    Is there a way for me to globally add a javascript block to all pages? I
    was hoping I could use one of the application events, but I don't seem to
    have access to the page object to use RegisterClientS criptBlock. Is there a
    way for me to accomplish this without adding something to every page?

    Thanks,
    -cliff


  • Oleg Ogurok

    #2
    Re: Register javascript block globally...


    Extend System.Web.UI.P age class, override its Render method and register
    your script there.
    Then simply have every codebehind class inherit from your newly created
    class.

    -Oleg.

    "Cliff Harris" <hersh@myrealbo x.com> wrote in message
    news:uVgQgs6UEH A.1888@TK2MSFTN GP11.phx.gbl...[color=blue]
    > Is there a way for me to globally add a javascript block to all pages? I
    > was hoping I could use one of the application events, but I don't seem to
    > have access to the page object to use RegisterClientS criptBlock. Is there[/color]
    a[color=blue]
    > way for me to accomplish this without adding something to every page?
    >
    > Thanks,
    > -cliff
    >
    >[/color]


    Comment

    • Guadala Harry

      #3
      Re: Register javascript block globally...

      You can create your own Page class that inherits from Page (i.e., extends
      Page), add RegisterStartup Script to it (plus anything else you want in all
      of your pages), and then have your ASPX pages inherit from your custom Page
      class.

      -GH


      "Cliff Harris" <hersh@myrealbo x.com> wrote in message
      news:uVgQgs6UEH A.1888@TK2MSFTN GP11.phx.gbl...[color=blue]
      > Is there a way for me to globally add a javascript block to all pages? I
      > was hoping I could use one of the application events, but I don't seem to
      > have access to the page object to use RegisterClientS criptBlock. Is there[/color]
      a[color=blue]
      > way for me to accomplish this without adding something to every page?
      >
      > Thanks,
      > -cliff
      >
      >[/color]


      Comment

      • Guadala Harry

        #4
        Re: Register javascript block globally...

        Correction... then have your aspx.cs or aspx.vb (your code behind
        classes)inherit from your new custom class.


        "Guadala Harry" <ChipsNSalsa@gh .com> wrote in message
        news:%23RfA526U EHA.4088@TK2MSF TNGP09.phx.gbl. ..[color=blue]
        > You can create your own Page class that inherits from Page (i.e., extends
        > Page), add RegisterStartup Script to it (plus anything else you want in all
        > of your pages), and then have your ASPX pages inherit from your custom[/color]
        Page[color=blue]
        > class.
        >
        > -GH
        >
        >
        > "Cliff Harris" <hersh@myrealbo x.com> wrote in message
        > news:uVgQgs6UEH A.1888@TK2MSFTN GP11.phx.gbl...[color=green]
        > > Is there a way for me to globally add a javascript block to all pages?[/color][/color]
        I[color=blue][color=green]
        > > was hoping I could use one of the application events, but I don't seem[/color][/color]
        to[color=blue][color=green]
        > > have access to the page object to use RegisterClientS criptBlock. Is[/color][/color]
        there[color=blue]
        > a[color=green]
        > > way for me to accomplish this without adding something to every page?
        > >
        > > Thanks,
        > > -cliff
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Cliff Harris

          #5
          Re: Register javascript block globally...

          Both your and Guadala's ideas are excellent... and that is what I would have
          done had I thought of this further in advance :)
          Unfortunately, I'm all done now and just want to add in the javascript, so I
          was hoping to find a way to just kinda insert it in at the last minute. I'm
          going to assume there is no real way to do that... so, maybe I'll get to
          work on changing all my pages to inherit from my own page class (thank
          goodness for Find/Replace).

          Thanks,
          -Cliff

          "Oleg Ogurok" <oleg@ogurok.co m.ihatespammers .ireallydo.co> wrote in message
          news:10d0lqqcrt s10e8@corp.supe rnews.com...[color=blue]
          >
          > Extend System.Web.UI.P age class, override its Render method and register
          > your script there.
          > Then simply have every codebehind class inherit from your newly created
          > class.
          >
          > -Oleg.
          >
          > "Cliff Harris" <hersh@myrealbo x.com> wrote in message
          > news:uVgQgs6UEH A.1888@TK2MSFTN GP11.phx.gbl...[color=green]
          > > Is there a way for me to globally add a javascript block to all pages?[/color][/color]
          I[color=blue][color=green]
          > > was hoping I could use one of the application events, but I don't seem[/color][/color]
          to[color=blue][color=green]
          > > have access to the page object to use RegisterClientS criptBlock. Is[/color][/color]
          there[color=blue]
          > a[color=green]
          > > way for me to accomplish this without adding something to every page?
          > >
          > > Thanks,
          > > -cliff
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...