Assembly: System.Web (in system.web.dll)
/** @property */ public boolean get_EnableClientScript () /** @property */ public void set_EnableClientScript (boolean value)
public function get EnableClientScript () : boolean public function set EnableClientScript (value : boolean)
Property Valuetrue to render the client-side script on compatible browsers; otherwise, false. The default is true.
Use the EnableClientScript property to specify whether the TreeView control renders client-side script on compatible browsers to handle expanding and collapsing events. When this property is set to true, compatible browsers execute the code to expand and collapse nodes on the client. The tree node data must be known in advance for the client-side script to work. Using client script prevents a post back to the server each time a node is expanded or collapsed.
When the tree node data is not known in advance, nodes can be populated from the client, if the PopulateNodesFromClient property is also set to true. In this scenario, you must also provide an event-handling method for the TreeNodePopulate event to populate the nodes. For more information on client-side node population, see PopulateNodesFromClient.
If the EnableClientScript property is set to false, the TreeView control posts back to the server each time a node is expanded or collapsed.
The value of this property is stored in view state.
This section contains two code examples. The first code example demonstrates how to use the EnableClientScript property to render client-side script that is used to expand and collapse nodes on compatible browsers. The second code example provides sample XML data for the first code example.
The following code example demonstrates how to use the EnableClientScript property to render client-side script that is used to expand and collapse nodes on compatible browsers. Notice that a post to the server is required to expand and collapse a node when the EnableClientScript property is set to false. For this example to work correctly, you must copy the sample XML data, provided after this code example, to a file named Book.xml.
<%@ Page Language="C#" %> <html> <body> <form runat="server"> <h3>TreeView EnableClientScript Example</h3> <asp:TreeView id="BookTreeView" DataSourceID="BookXmlDataSource" EnableClientScript="true" runat="server"> <DataBindings> <asp:TreeNodeBinding DataMember="Book" TextField="Title"/> <asp:TreeNodeBinding DataMember="Chapter" TextField="Heading"/> <asp:TreeNodeBinding DataMember="Section" TextField="Heading"/> </DataBindings> </asp:TreeView> <asp:XmlDataSource id="BookXmlDataSource" DataFile="Book.xml" runat="server"> </asp:XmlDataSource> </form> </body> </html>
The following code example provides sample XML data for the preceding code example.
<Book Title="Book Title"> <Chapter Heading="Chapter 1"> <Section Heading="Section 1"> </Section> <Section Heading="Section 2"> </Section> </Chapter> <Chapter Heading="Chapter 2"> <Section Heading="Section 1"> </Section> </Chapter> </Book>
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.