Prevent postbacks in asp.net IEWC treeview

Here is the solution for two common requirements for iewc treeview.

1. How to prevent postback when user is expanding, collapsing, checking or unchecking the treeview? (This is an example for oncheck. You can use other events too like onclick)
A) TreeView1.Attributes(“oncheck”) = “return Treeview_Hijack_OnCheck();” to your page_load()

B) Add this to your .aspx : <script lang=javascript>function Treeview_Hijack_OnCheck(){}</script>

Be aware that although this will prevent postbacks, but server side DOM for the treeview will no more give you a reliable value for node.checked property. In this case there is no utility of the above example, but its just a way to prevent postbacks, u can do the same for clicks, expands or any other event of the tree.

2. If you want to retain your postbacks but want a good user experience so that the page doesnt keep loading everytime you click or check a node then just turn Smartnavigation for your page on. You will like the results.

Advertisements

6 thoughts on “Prevent postbacks in asp.net IEWC treeview

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s