Two WebControls Same Page, big problems

Discussion in 'ASP .Net Building Controls' started by Brooks Of Sheffield, Oct 24, 2003.

  1. I have written a composite treeview webcontrol. It has a "Filtered"
    property. During the Render process, if the Filtered property is set
    to True it will add a checkbox, if the Filtered is set to False it
    should NOT add a checkbox.

    If I put just one instance of the webcontrol on a page, it works as
    expected.

    But if I drop two of them, and then change the Filtered property of
    the second one to True, BOTH of them render with checkboxes --
    obviously I only want the second one too. How are the two getting
    mixed up?

    Another clue: the control overrides OnInit to track a couple objects:

    OnInit ...
    if PostBack.PostBack
    _LastNodeClicked = Page.Session.Item("LNC")

    The controls were "mixing up" the LNCs, each responding to the last
    node clicked on the page, not the last node clicked on the specific
    control. I added the "UniqueId" to the session variables and that
    fixed that problem:

    Page.Session.Add("LNC"+Me.UniqueID, N)
    _LastNodeClicked = Page.Session.Item("LNC"+Me.UniqueID)

    But I suspect that both behaviors are symptoms of the same underlying
    (probably obvious?) problem. Does anyone know what I am doing wrong?

    Thanks,

    Brooks
    Brooks Of Sheffield, Oct 24, 2003
    #1
    1. Advertising

  2. Hi,

    >>>> I have written a composite treeview webcontrol...
    >>>> But if I drop two of them...


    Can't say much without actually looking at some code but from your two
    previous lines it seems like your controls' IDs may be messing. Are you
    implementing the INamingContainer marker interface in your composite
    control? Are you using the ClientID property (instead of ID or UniqueID) to
    reference id rendered to the browser?


    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx
    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    and not by private mail.

    "Brooks Of Sheffield" <> wrote in message
    news:...
    > I have written a composite treeview webcontrol. It has a "Filtered"
    > property. During the Render process, if the Filtered property is set
    > to True it will add a checkbox, if the Filtered is set to False it
    > should NOT add a checkbox.
    >
    > If I put just one instance of the webcontrol on a page, it works as
    > expected.
    >
    > But if I drop two of them, and then change the Filtered property of
    > the second one to True, BOTH of them render with checkboxes --
    > obviously I only want the second one too. How are the two getting
    > mixed up?
    >
    > Another clue: the control overrides OnInit to track a couple objects:
    >
    > OnInit ...
    > if PostBack.PostBack
    > _LastNodeClicked = Page.Session.Item("LNC")
    >
    > The controls were "mixing up" the LNCs, each responding to the last
    > node clicked on the page, not the last node clicked on the specific
    > control. I added the "UniqueId" to the session variables and that
    > fixed that problem:
    >
    > Page.Session.Add("LNC"+Me.UniqueID, N)
    > _LastNodeClicked = Page.Session.Item("LNC"+Me.UniqueID)
    >
    > But I suspect that both behaviors are symptoms of the same underlying
    > (probably obvious?) problem. Does anyone know what I am doing wrong?
    >
    > Thanks,
    >
    > Brooks
    Victor Garcia Aprea [MVP], Oct 24, 2003
    #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. Replies:
    11
    Views:
    713
    Roedy Green
    Sep 18, 2005
  2. Shaguf
    Replies:
    0
    Views:
    349
    Shaguf
    Dec 24, 2008
  3. Shaguf
    Replies:
    0
    Views:
    447
    Shaguf
    Dec 26, 2008
  4. Shaguf
    Replies:
    0
    Views:
    235
    Shaguf
    Dec 26, 2008
  5. Shaguf
    Replies:
    0
    Views:
    214
    Shaguf
    Dec 24, 2008
Loading...

Share This Page