Two WebControls Same Page, big problems

  • Thread starter Brooks Of Sheffield
  • Start date
B

Brooks Of Sheffield

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
 
V

Victor Garcia Aprea [MVP]

Hi,

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top