Thanks again Amanda, I think I'm really making progress with this now just one more question (hopefully). In you sample code you have the line:
Amanda Wang - MSFT:writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.GetPostBackEventReference(this, "Previous"));
This is inside the TreeNode which does not extend System.Web.UI.WebControls.Control, as far as I'm aware therefore how can you pass 'this' as an argument to GetPostBackEventReference?
I have included my class for you to help advice me.
1 using System.Web.UI;
2 using System.Web;
3 using System.Web.UI.WebControls;
4 using System.Web.UI.HtmlControls;
5
6 namespace MyNamespace
7 {
8 public class MyTreeNode: TreeNode, IPostBackEventHandler
9 {
10
11 #region Constructors
12
13 public MyTreeNode()
14 {
15 }
16
17 public MyTreeNode( string text ) : base( text )
18 {
19 this.SelectAction = TreeNodeSelectAction.Select;
20 }
21
22 #endregion
23
24 #region Protected methods
25
26 protected override void RenderPostText( HtmlTextWriter writer )
27 {
28 Page page = HttpContext.Current.Handler as Page;
29 ClientScriptManager csm = page.ClientScript;
30
31 writer.AddAttribute( HtmlTextWriterAttribute.Onclick, csm.GetPostBackEventReference( this, "Delete" ) );
32 writer.RenderBeginTag( HtmlTextWriterTag.Button );
33 writer.Write( "Delete" );
34 writer.RenderEndTag();
35
36 writer.AddAttribute( HtmlTextWriterAttribute.Onclick, csm.GetPostBackEventReference( this, "Next" ) );
37 writer.RenderBeginTag( HtmlTextWriterTag.Button );
38 writer.Write( "Next" );
39 writer.RenderEndTag();
40
41 base.RenderPostText( writer );
42 }
43
44 #endregion
45
46 #region event handlers
47
48 public void RaisePostBackEvent( string eventArgument )
49 {
50 if ( "Delete" == eventArgument )
51 {
52 OnClickDelete( EventArgs.Empty );
53 }
54 else if ( "Next" == eventArgument )
55 {
56 OnClickNext( EventArgs.Empty );
57 }
58 }
59
60
61 private void OnClickDelete( EventArgs e )
62 {
63 throw new NotImplementedException();
64 }
65
66 private void OnClickNext( EventArgs e )
67 {
68 throw new NotImplementedException();
69 }
70
71 #endregion
72
73 }
74 }
Thanks again, your help is really appreciated.