I want to do a process once per page process, but 'touch' all instances of my server control.

Discussion in 'ASP .Net Web Controls' started by Jason Kendall, Jun 1, 2005.

  1. I have a server control that emits some client side script. Rather
    than have a script block for every instance of my server control, I'd
    like to have one block that contains the code for all of instances.

    I have looked into the OnInit, OnLoad and OnPreRender events, but the
    "MyBase.Page.Controls" collection never seems to contain my controls.

    Any tips would be appreciated.


    -Jason Kendall
     
    Jason Kendall, Jun 1, 2005
    #1
    1. Advertising

  2. Jason Kendall

    Patrice Guest

    Looks you have two different issues ?

    Try IsClientScriptRegistered/RegisterClientScriptBlock. It allows to avoid
    rendering the script if it has already been rendered previously...

    For the second point you'll likely have to elaborate a bit...How do you look
    at Page.Controls (your controls might be itself inside an inner control ?).
    What if you start by looking at the HTML ? Do you see what your control is
    supposed to render ? If should be a fairly good indication of wether or not
    your control is actually in the control hierarchy...

    Patrice


    --

    "Jason Kendall" <> a écrit dans le message de
    news:...
    > I have a server control that emits some client side script. Rather
    > than have a script block for every instance of my server control, I'd
    > like to have one block that contains the code for all of instances.
    >
    > I have looked into the OnInit, OnLoad and OnPreRender events, but the
    > "MyBase.Page.Controls" collection never seems to contain my controls.
    >
    > Any tips would be appreciated.
    >
    >
    > -Jason Kendall
    >
     
    Patrice, Jun 1, 2005
    #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. chris brat
    Replies:
    1
    Views:
    669
    chris brat
    May 10, 2006
  2. MRW
    Replies:
    0
    Views:
    284
  3. lds
    Replies:
    0
    Views:
    401
  4. gnewsgroup
    Replies:
    1
    Views:
    789
    bruce barker
    Dec 20, 2007
  5. Han Holl
    Replies:
    4
    Views:
    367
    Nobuyoshi Nakada
    Oct 12, 2006
Loading...

Share This Page