[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

how to access the Page from a TreeNode (treeview 's element) : adding a context menu to a treeview

abargaddon

1/17/2008 11:06:00 AM

Hi all,

I have derived the TreeNode class in order to have it templated, and
that works well. However, in the template I put a control (a link to a
menu) that refers to another control (the menu itself) in the page but
outside the template.

It does not work because the inner control (link to a menu) fails to
find the other control, which it searches in its Page attribute. It
looks like the Page property is null when in a template.

The code is in VB.NET, which I like less than C# :

Protected Overrides Sub AddAttributesToRender(ByVal writer As
System.Web.UI.HtmlTextWriter)
If Not (System.Web.HttpContext.Current Is Nothing) AndAlso Not
Me.Page Is Nothing AndAlso Me.Enabled AndAlso
Me.ContextMenuToOpen.Length > 0 Then

That test fails because Me.Page is Nothing.

So, how can I set the Page attribute of each TreeNode, or access the
TreeView object from the TreeNode object ?

Thanks in advance,
Abargaddon