Tuesday, August 14, 2007

ASP.Net TreeView doesn't have AutoPostback

I have a TreeView ASP.Net control where clicking the node would go to the DetailsView while the checkbox represented an action/state of that node. I wanted the check action to happen immediately like you can do with a normal CheckBox, however the ASP.NET TreeView is optimized so it actually does not even have even have child controls but instead "renders" as a single control. In other words it does not generate an ASP.NET CheckBox as a child control instead it renders the markup for an input type="checkbox".

So it seems like there is no possible modify the TreeView to add checkbox autopostback behaviors without redoing the whole control.

It would be nice if the TreeView had a templated TreeNode but that would be a huge departure from the current behavior.

Also on my list of nice things to have for the TreeView would be: Reordering and Popup menu behaviors like MS Live Hotmail's folder features.

As a workaround, I suppose I drop the NavigateUrl that goes to the DetailsView page and use the a blank SelectAction which does cause a postback to check the checkbox and perform the action.