ASP.NET Hosting

Custom TreeView without behavior

On a project I have worked on, we needed to display a tree view in an ASPX page. The client needed the ability to print the page through IE print command. We started to use the TreeView control coming with the IE Web Controls released by the ASP.NET team. Then we realized that the tree view was not printing correctly due to the use of a client behavior coming with the TreeView server control. The client behavior is automatically activated on IE 5.5+, and deactivated for previous or non IE browsers. ...But, the client behavior cannot be deactivated on up-level browsers!

I was not panicked as luckily MS had released the source code of the IE Web Controls not long before. After some investigation in the existing code, I found a way to create a custom TreeView control that would allow the client behavior to be deactivated. My TreeView is just an extension of the base TreeView with an added BehaviorUsage property which values can be Default, Deactivated or Forced. The source code is available for your curiosity or use.

This case is just an other example of the advantages of releasing source code...

2 Comments

  • I am trying to use your control. When I deactivate the behavior the print works fine but now it is trying to do postback when I click on any node and I do not want to do the postback. can you tell me how I can disable to postback. Autopostback is off on the control



    Thanks

  • I don't think this is possible without changing the source code and adding some javascript.

    I didn't need to do this. You'll have to dig in the source code.

Comments have been disabled for this content.