aspnet_treeview

86
ComponentOne TreeView for ASP.NET

Upload: tio-lampard-chelsea-fc

Post on 08-Nov-2015

2 views

Category:

Documents


0 download

DESCRIPTION

IT

TRANSCRIPT

  • ComponentOne

    TreeView for ASP.NET

  • Copyright 1987-2010 ComponentOne LLC. All rights reserved.

    Corporate HeadquartersComponentOne LLC201 South Highland Avenue3rd FloorPittsburgh, PA 15206 USA

    Internet: [email protected] site: http://www.componentone.comSalesE-mail: [email protected]: 1.800.858.2739 or 1.412.681.4343 (Pittsburgh, PA USA Office)

    Trademarks

    The ComponentOne product name is a trademark and ComponentOne is a registered trademark of ComponentOne LLC. All other trademarks used herein are the properties of their respective owners.

    Warranty

    ComponentOne warrants that the original CD (or diskettes) are free from defects in material and workmanship, assuming normal use, for a period of 90 days from the date of purchase. If a defect occurs during this time, you may return the defective CD (or disk) to ComponentOne, along with a dated proof of purchase, and ComponentOne will replace it at no charge. After 90 days, you can obtain a replacement for a defective CD (or disk) by sending it and a check for $25 (to cover postage and handling) to ComponentOne.

    Except for the express warranty of the original CD (or disks) set forth here, ComponentOne makes no other warranties, express or implied. Every attempt has been made to ensure that the information contained in this manual is correct as of the time it was written. We are not responsible for any errors or omissions. ComponentOnes liability is limited to the amount you paid for the product. ComponentOne is not liable for any special, consequential, or other damages for any reason.

    Copying and Distribution

    While you are welcome to make backup copies of the software for your own use and protection, you are not permitted to make copies for the use of anyone else. We put a lot of time and effort into creating this product, and we appreciate your support in seeing that it is used by licensed users only.

    This manual was produced using ComponentOne Doc-To-Help.

  • iii

    Table of ContentsComponentOne TreeView for ASP.NET Overview ...................................................................... 1

    What's New in ComponentOne TreeView for ASP.NET.......................................................................1Revision History.................................................................................................................................1Whats New in 2009 v3 .......................................................................................................................1Installing TreeView for ASP.NET........................................................................................................2TreeView for ASP.NET Setup Files .....................................................................................................2System Requirements..........................................................................................................................3Uninstalling TreeView for ASP.NET ...................................................................................................3Deploying your Application in a Medium Trust Environment................................................................3End-User License Agreement...............................................................................................................6Licensing FAQs..................................................................................................................................6What is Licensing?..............................................................................................................................6How does Licensing Work? .................................................................................................................7Common Scenarios.............................................................................................................................7Common Scenarios in Mobile Applications ..........................................................................................9Troubleshooting................................................................................................................................ 11Technical Support............................................................................................................................. 12Redistributable Files.......................................................................................................................... 13About This Documentation ............................................................................................................... 13Namespaces ..................................................................................................................................... 14Creating an AJAX-Enabled ASP.NET Project .................................................................................... 15Adding the C1TreeView Component to a Project ................................................................................ 17

    Key Features.......................................................................................................................18

    TreeView for ASP.NET Quick Start.........................................................................................20Adding C1TreeView to the Page ........................................................................................................ 20Creating a TreeView Using the Designer ............................................................................................ 20Binding C1TreeView to an XML File................................................................................................. 23

    TreeView for ASP.NET Top Tips............................................................................................25

    Design-Time Support............................................................................................................28C1TreeView Smart Tag ..................................................................................................................... 28C1TreeViewNodeBinding Collection Editor ....................................................................................... 30C1TreeView Context Menu............................................................................................................... 31TreeView Designer Form .................................................................................................................. 32Exploring the TreeView Designer Form ............................................................................................. 33

    TreeView Structure ..............................................................................................................37

    TreeView Elements ..............................................................................................................37

    TreeView Creation...............................................................................................................38Static TreeView Creation................................................................................................................... 38Dynamic TreeView Creation ............................................................................................................. 39Data Source TreeView Creation......................................................................................................... 42

    TreeView Behavior ..............................................................................................................42Animation........................................................................................................................................ 42Expand and Collapse Animation Effects............................................................................................. 42Expand and Collapse Transitions....................................................................................................... 44Expand and Collapse Duration.......................................................................................................... 46Check Boxes..................................................................................................................................... 46

  • iv

    Drag and Drop Nodes....................................................................................................................... 47Load on Demand.............................................................................................................................. 47Node Selection ................................................................................................................................. 48Node Navigation .............................................................................................................................. 49

    TreeView Appearance...........................................................................................................49Visual Styles ..................................................................................................................................... 50Custom Visual Styles......................................................................................................................... 51Templates......................................................................................................................................... 52

    Client-Side TreeView ...........................................................................................................52Client-Side Properties........................................................................................................................ 52Client-Side Methods.......................................................................................................................... 52Client-Side Events............................................................................................................................. 52

    TreeView for ASP.NET Samples .............................................................................................56

    TreeView for ASP.NET Task-Based Help .................................................................................56Adding Collapse and Expand Animation Effects................................................................................. 56Binding C1TreeView to a Site Map .................................................................................................... 59Preventing C1TreeViewNode from Losing its Selected State ................................................................ 61Load and Save C1TreeView through XML......................................................................................... 62Save the Tree as an XML .................................................................................................................. 62Load an Existing XML TreeView into your Project............................................................................. 62Designer Tasks ................................................................................................................................. 63Deleting a C1TreeViewNode............................................................................................................. 63Renaming the TreeViewNode in the Designer..................................................................................... 65Adding a Child Node ........................................................................................................................ 66Inserting a Node ............................................................................................................................... 68Adding, Inserting, and Removing Nodes Dynamically ........................................................................ 69Add a Node Dynamically.................................................................................................................. 69Insert a Node Dynamically ................................................................................................................ 73Remove a Node Dynamically ............................................................................................................ 76Displaying Static Data....................................................................................................................... 79Retrieving the full node path using the OnMouseOver Event ............................................................... 80

  • 1ComponentOne TreeView for ASP.NET Overview

    Getting StartedCreate highly sophisticated navigational systems in your ASP.NET applications with ComponentOne TreeView for ASP.NET. The C1TreeView controls easy to use designers, support for Cascading Style Sheets (CSS) and templates, and built-in animation effects gives you a customizable and flexible treeview control that is very easy to use. The rich client-side object model enables you to use client-side events for more client-side interactivity.

    TreeView for ASP.NET is part of ComponentOne Studio for ASP.NET, the next breed of ASP.NET controls developed on a new client and server side framework. This new ASP.NET control suite fully exploits the AJAX framework to enable you to create highly interactive and sophisticated Web applications with Studio for ASP.NET.

    - TreeView for ASP.NET Quick Start (page 20)

    - TreeView Elements (page 37)

    - TreeView Behavior (page 42)

    What's New in ComponentOne TreeView for ASP.NETThis documentation was last revised on February 22, 2010. There were no new features added to ComponentOne TreeView for ASP.NET.

    Tip: A version history containing a list of new features, improvements, fixes, and changes for each product is available in HelpCentral at http://helpcentral.componentone.com/VersionHistory.aspx.

    Revision HistoryThe revision history provides recent enhancements to TreeView for ASP.NET.

    What's New in 2009 v3This documentation was last revised on September 10, 2009.

    A new feature has been added to ComponentOne TreeView for ASP.NET in the 2009 v3 release:

    New Features

    C1TreeView now supports Tri-State checkboxes. To enable tri-state checkboxes set the AllowTriState property to true. The following image displays how the three different checkbox states visually effect the checkboxes next to the C1TreeViewNodes:

  • 2For more information on tristate checkboxes, see Check Boxes (page 46).

    Installing TreeView for ASP.NET The following sections provide helpful information on installing ComponentOne Studio for ASP.NET:

    TreeView for ASP.NET Setup FilesThe ComponentOne Studio for ASP.NET installation program will create the following directory: C:\Program Files\ComponentOne\Studio for ASP.NET. This directory contains the following subdirectories:

    bin Contains copies of all binaries (DLLs, EXEs) in the ComponentOne Visual Studio ASP.NET package.

    Common Contains support and data files that are used by many of the demo programs.

    C1.Web.UI Contains files (at least a readme.txt) related to the C1WebUI product.

    C1WebUi\VisualStyles Contains all external file themes.

    Samples

    Samples for the product are installed in the ComponentOne Samples folder by default. The path of the ComponentOne Samples directory is slightly different on Windows XP and Windows 7/Vista machines:

    Windows XP path: C:\Documents and Settings\\My Documents\ComponentOne Samples

    Windows 7/Vista path: C:\Users\\Documents\ComponentOne Samples

    The ComponentOne Samples folder contains the following subdirectories:

    Common Contains support and data files that are used by many of the demo programs.

    C1WebUi Contains a Samples folder for the Visual Studio sample project and a

  • 3readme.txt file.

    System RequirementsSystem requirements for ComponentOne Studio for ASP.NET components include the following:

    Operating Systems: Windows 2000

    Windows Server 2003

    Windows Server 2008

    Windows XP SP2

    Windows Vista

    Windows 7

    Web Server: Microsoft Internet Information Services (IIS) 5.0 or later

    Environments: .NET Framework 2.0 or later

    Visual Studio 2005 or Visual Studio 2008

    Internet Explorer 6.0 or later

    Firefox 2.0 or later

    Safari 2.0 or later

    Uninstalling TreeView for ASP.NETTo uninstall TreeView for ASP.NET:

    1. Open the Control Panel and select the Add or Remove Programs (Programs and Features in 7/Vista).

    2. Select ComponentOne Studio for ASP.NETand click the Remove button.

    3. Click Yes to remove the program.

    Deploying your Application in a Medium Trust EnvironmentDepending on your hosting choice, you may need to deploy your Web site or application in a medium trust environment. Often in a shared hosting environment, medium trust is required. In a medium trust environment several permissions are unavailable or limited, including OleDbPermission, ReflectionPermission, and FileIOPermission. You can configure your Web.config file to enable these permissions.

    Note: ComponentOne controls will not work in an environment where reflection is not allowed.

    ComponentOne ASP.NET controls include the AllowPartiallyTrustedCallers() assembly attribute and will work under the medium trust level with some changes to the Web.config file. Since this requires some control over the Web.config file, please check with your particular host to determine if they can provide the rights to override these security settings.

    Modifying or Editing the Config FileIn order to add permissions, you can edit the exiting web_mediumtrust.config file or create a custom policy file based on the medium trust policy. If you modify the existing web_mediumtrust.config file, all Web applications will have the same permissions with the permissions you have added. If you want applications to have different permissions, you can instead create a custom policy based on medium trust.

  • 4Edit the Config File

    In order to add permissions, you can edit the exiting web_mediumtrust.config file. To edit the exiting web_mediumtrust.config file, complete the following steps:

    1. Locate the medium trust policy file web_mediumtrust.config located by default in the %windir%\Microsoft.NET\Framework\{Version}\CONFIG directory.

    2. Open the web_mediumtrust.config file.

    3. Add the permissions that you want to grant. For examples, see Adding Permissions (page 5).

    Create a Custom Policy Based on Medium Trust

    In order to add permissions, you can create a custom policy file based on the medium trust policy. To create a custom policy file, complete the following steps:

    1. Locate the medium trust policy file web_mediumtrust.config located by default in the %windir%\Microsoft.NET\Framework\{Version}\CONFIG directory.

    2. Copy the web_mediumtrust.config file and create a new policy file in the same directory.

    Give the new a name that indicates that it is your variation of medium trust; for example, AllowReflection_Web_MediumTrust.config.

    3. Add the permissions that you want to grant. For examples, see Adding Permissions (page 5).

    4. Enable the custom policy file on your application by modifying the following lines in your web.config file under the node:

    ...

    Note: Your host may not allow trust level overrides. Please check with your host to see if you have these rights.

    Allowing DeserializationTo allow the deserialization of the license added to App_Licenses.dll by the Microsoft IDE, you should add the SerializationFormatter flag to security permission to the Web.config file. Complete the steps in the Modifying or Editing the Config File (page 3) topic to create or modify a policy file before completing the following.

    Add the SerializationFormatter flag to the tag so that it appears similar to the following:

    ...

  • 5

    Adding PermissionsYou can add permission, including ReflectionPermission, OleDbPermission, and FileIOPermission, to the web.config file. Note that ComponentOne controls will not work in an environment where reflection is not allowed. Complete the steps in the Modifying or Editing the Config File (page 3) topic to create or modify a policy file before completing the following.

    ReflectionPermission

    By default ReflectionPermission is not available in a medium trust environment. ComponentOne ASP.NET controls require reflection permission because LicenseManager.Validate() causes a link demand for full trust.

    To add reflection permission, complete the following:

    1. Open the web_mediumtrust.config file or a file created based on the web_mediumtrust.config file.

    2. Add the following tag after the tag so that it appears similar to the following:

    ...

    3. Add the following tag after the tag so it appears similar to the following:

    ...

    4. Save and close the web_mediumtrust.config file.

    OleDbPermission

    By default OleDbPermission is not available in a medium trust environment. This means you cannot use the ADO.NET managed OLE DB data provider to access databases. If you wish to use the ADO.NET managed OLE DB data provider to access databases, you must modify the web_mediumtrust.config file.

    To add OleDbPermission, complete the following steps:

    1. Open the web_mediumtrust.config file or a file created based on the web_mediumtrust.config file.

    2. Add the following tag after the tag so that it appears similar to the following:

    ...

    3. Add the following tag after the tag so it appears similar to the following:

  • 6

    ...

    4. Save and close the web_mediumtrust.config file.

    FileIOPermission

    By default, FileIOPermission is not available in a medium trust environment. This means no file access is permitted outside of the application's virtual directory hierarchy. If you wish to allow additional file permissions, you must modify the web_mediumtrust.config file.

    To modify FileIOPermission to allow read access to a specific directory outside of the application's virtual directory hierarchy, complete the following steps:

    1. Open the web_mediumtrust.config file or a file created based on the web_mediumtrust.config file.

    2. Add the following tag after the tag so that it appears similar to the following:

    ...

    3. Add the following tag after the tag so it appears similar to the following:

    ...

    ...

    4. Save and close the web_mediumtrust.config file.

    End-User License AgreementAll of the ComponentOne licensing information, including the ComponentOne end-user license agreements, the ComponentOne licensing model, and frequently asked licensing questions, is available online at http://www.componentone.com/SuperPages/Licensing/.

    Licensing FAQsThis section describes the main technical aspects of licensing. It may help the user to understand and resolve licensing problems he may experience when using ComponentOne .NET and ASP.NET products.

    What is Licensing?Licensing is a mechanism used to protect intellectual property by ensuring that users are authorized to use software products.

  • 7Licensing is not only used to prevent illegal distribution of software products. Many software vendors, including ComponentOne, use licensing to allow potential users to test products before they decide to purchase them.

    Without licensing, this type of distribution would not be practical for the vendor or convenient for the user. Vendors would either have to distribute evaluation software with limited functionality, or shift the burden of managing software licenses to customers, who could easily forget that the software being used is an evaluation version and has not been purchased.

    How does Licensing Work?ComponentOne uses a licensing model based on the standard set by Microsoft, which works with all types of components.

    Note: The Compact Framework components use a slightly different mechanism for run-time licensing than the other ComponentOne components due to platform differences.

    When a user decides to purchase a product, he receives an installation program and a Serial Number. During the installation process, the user is prompted for the serial number that is saved on the system. (Users can also enter the serial number by clicking the License button on the About Box of any ComponentOne product, if available, or by rerunning the installation and entering the serial number in the licensing dialog.)

    When a licensed component is added to a form or web page, Visual Studio obtains version and licensing information from the newly created component. When queried by Visual Studio, the component looks for licensing information stored in the system and generates a run-time license and version information, which Visual Studio saves in the following two files:

    An assembly resource file which contains the actual run-time license

    A "licenses.licx" file that contains the licensed component strong name and version information

    These files are automatically added to the project by Microsoft Visual Studio.

    In WinForms and ASP.NET 1.x applications, the run-time license is stored as an embedded resource in the assembly hosting the component or control by Visual Studio. In ASP.NET 2.x applications, the run-time license may also be stored as an embedded resource in the App_Licenses.dll assembly, which is used to store all run-time licenses for all components directly hosted by WebForms in the application. Thus, the App_licenses.dll must always be deployed with the application.

    The licenses.licx file is a simple text file that contains strong names and version information for each of the licensed components used in the application. Whenever Visual Studio is called upon to rebuild the application resources, this file is read and used as a list of components to query for run-time licenses to be embedded in the appropriate assembly resource. Note that editing or adding an appropriate line to this file can force Visual Studio to add run-time licenses of other controls as well.

    Note that the licenses.licx file is usually not shown in the Solution Explorer; it appears if you press the Show All Files button in the Solution Explorer's toolbox, or from Visual Studio's main menu, select Show All Files on the Project menu.

    Later, when the component is created at run time, it obtains the run-time license from the appropriate assembly resource that was created at design time and can decide whether to simply accept the run-time license, to throw an exception and fail altogether, or to display some information reminding the user that the software has not been licensed.

    All ComponentOne products are designed to display licensing information if the product is not licensed. None will throw licensing exceptions and prevent applications from running.

    Common ScenariosThe following topics describe some of the licensing scenarios you may encounter.

  • 8Creating components at design timeThis is the most common scenario and also the simplest: the user adds one or more controls to the form, the licensing information is stored in the licenses.licx file, and the component works.

    Note that the mechanism is exactly the same for Windows Forms and Web Forms (ASP.NET) projects.

    Creating components at run time This is also a fairly common scenario. You do not need an instance of the component on the form, but would like to create one or more instances at run time.

    In this case, the project will not contain a licenses.licx file (or the file will not contain an appropriate run-time license for the component) and therefore licensing will fail.

    To fix this problem, add an instance of the component to a form in the project. This will create the licenses.licx file and things will then work as expected. (The component can be removed from the form after the licenses.licx file has been created).

    Adding an instance of the component to a form, then removing that component, is just a simple way of adding a line with the component strong name to the licenses.licx file. If desired, you can do this manually using notepad or Visual Studio itself by opening the file and adding the text. When Visual Studio recreates the application resources, the component will be queried and its run-time license added to the appropriate assembly resource.

    Inheriting from licensed componentsIf a component that inherits from a licensed component is created, the licensing information to be stored in the form is still needed. This can be done in two ways:

    Add a LicenseProvider attribute to the component.

    This will mark the derived component class as licensed. When the component is added to a form, Visual Studio will create and manage the licenses.licx file, and the base class will handle the licensing process as usual. No additional work is needed. For example:

    [LicenseProvider(typeof(LicenseProvider))]class MyGrid: C1.Win.C1FlexGrid.C1FlexGrid{// ...

    } Add an instance of the base component to the form.

    This will embed the licensing information into the licenses.licx file as in the previous scenario, and the base component will find it and use it. As before, the extra instance can be deleted after the licenses.licx file has been created.

    Please note, that C1 licensing will not accept a run time license for a derived control if the run time license is embedded in the same assembly as the derived class definition, and the assembly is a DLL. This restriction is necessary to prevent a derived control class assembly from being used in other applications without a design time license. If you create such an assembly, you will need to take one of the actions previously described create a component at run time.

    Using licensed components in console applicationsWhen building console applications, there are no forms to add components to, and therefore Visual Studio won't create a licenses.licx file.

    In these cases, create a temporary Windows Forms application and add all the desired licensed components to a form. Then close the Windows Forms application and copy the licenses.licx file into the console application project.

  • 9Make sure the licenses.licx file is configured as an embedded resource. To do this, right-click the licenses.licx file in the Solution Explorer window and select Properties. In the Properties window, set the Build Action property to Embedded Resource.

    Using licensed components in Visual C++ applicationsThere is an issue in VC++ 2003 where the licenses.licx is ignored during the build process; therefore, the licensing information is not included in VC++ applications.

    To fix this problem, extra steps must be taken to compile the licensing resources and link them to the project. Note the following:

    1. Build the C++ project as usual. This should create an exe file and also a licenses.licx file with licensing information in it.

    2. Copy the licenses.licx file from the app directory to the target folder (Debug or Release).

    3. Copy the C1Lc.exe utility and the licensed dlls to the target folder. (Don't use the standard lc.exe, it has bugs.)

    4. Use C1Lc.exe to compile the licenses.licx file. The command line should look like this:c1lc /target:MyApp.exe /complist:licenses.licx /i:C1.Win.C1FlexGrid.dll

    5. Link the licenses into the project. To do this, go back to Visual Studio, right-click the project, select properties, and go to the Linker/Command Line option. Enter the following:/ASSEMBLYRESOURCE:Debug\MyApp.exe.licenses

    6. Rebuild the executable to include the licensing information in the application.

    Using licensed components with automated testing productsAutomated testing products that load assemblies dynamically may cause them to display license dialogs. This is the expected behavior since the test application typically does not contain the necessary licensing information, and there is no easy way to add it.

    This can be avoided by adding the string "C1CheckForDesignLicenseAtRuntime" to the AssemblyConfiguration attribute of the assembly that contains or derives from ComponentOne controls. This attribute value directs the ComponentOne controls to use design time licenses at run time.

    For example:#if AUTOMATED_TESTING

    [AssemblyConfiguration("C1CheckForDesignLicenseAtRuntime")]#endif

    public class MyDerivedControl : C1LicensedControl{

    // ...}

    Note that the AssemblyConfiguration string may contain additional text before or after the given string, so the AssemblyConfiguration attribute can be used for other purposes as well. For example:

    [AssemblyConfiguration("C1CheckForDesignLicenseAtRuntime,BetaVersion")]THIS METHOD SHOULD ONLY BE USED UNDER THE SCENARIO DESCRIBED. It requires a design time license to be installed on the testing machine. Distributing or installing the license on other computers is a violation of the EULA.

    Common Scenarios in Mobile ApplicationsThe following topics describe some of the licensing scenarios you may encounter when working with Mobile components.

  • 10

    Updating or renewing a licenseIf you renew your subscription, the new license must be installed.

    If the Mobile controls are licensed through a Studio subscription, then open the About Box of either an ASP.NET control or a .NET Windows forms control and update the license by clicking the License button and entering your serial number.

    If the Mobile controls are licensed through a Studio for Mobile Devices subscription, then open the About Box of the 1.x version of a Mobile control or run the setup again to enter your serial number. Presently, the 2.x versions of the Mobile controls do not have the option to license or register from the About Box; therefore, it is necessary to license through another component or the setup.

    Licensing 2.x Mobile Controls through the Setup

    To enter the serial number (license) through the Studio for Mobile Devices 2.0 setup, follow these steps:

    1. Run the ComponentOne Studio for Mobile Devices 2.0 setup.

    2. Follow the instructions in the setup, and enter the serial number when prompted.

    There are cases where the setup may not prompt you. If you have a valid license installed already, or if you are installing a version of the controls that has already been installed (Maintenance Mode), you will not be prompted to enter your serial number. If you need to enter your serial number for an install, and the install is running in Maintenance Mode, you will need to uninstall first. Once you uninstall, run the install again.

    If you are still not prompted for a serial number by the time you get to the install screen, you must have a valid license in the registry on your machine. If you still need to install a new serial number, remove the old license and then run the setup again. There is a utility available that will remove the old license for you, which can be found below.

    License Remover

    The license remover will search for the following licenses on your system: Studio Enterprise, Studio for Mobile Devices, and individual Studio Mobile product licenses. Any licenses that are found will be populated into a list so that you can select the ones that you would like to remove. To remove a Studio for Mobile Devices license with the license remover, follow these steps:

    1. Unzip and run the C1LicBomb.exe.

    2. You will see an app with a list of the installed licenses on your machine. If you see both Studio Enterprise and Studio for Mobile devices listed, select both for removal, otherwise select the one that you see. If the new serial number that you wish to enter for Studio for Mobile Devices is not a Studio Enterprise serial number, you will need to enter your Studio Enterprise serial number again, but this can be done through any of the About Boxes for C1 controls with the exception of the Mobile Studio About Boxes.

    3. Select any other licenses you wish to remove, then click the Remove Selected Licenses button.

    4. You will be asked if you are sure that you want to delete each key; click OK when you get the dialog box.

    5. There will also be a dialog box to let you know that a particular key was removed successfully; click OKfor that one also.

    6. Now you can close the program and run your Studio for Mobile Devices setup again to enter your new serial number.

    Follow through with the setup, enter your serial number when prompted, and ComponentOne Studio for Mobile Devices will be licensed on your machine.

    Updating a project after renewing a licenseOnce you have installed a new license, each project must be updated in order to use the new control; rebuilding the control is not sufficient. It is necessary for the control to regenerate the license embedded in its SupportInfoproperty. To do this, it is necessary to force Visual Studio to update the control properties stored in the form. The

  • 11

    easiest way to do this is to simply modify a property. The simplest choice is to toggle a Boolean property such as the Visible property, and then toggle it back to its original value. This results in no changes or side effects in the control configuration, but it forces the IDE to update SupportInfo and embed the new run-time license.

    Instantiating a Mobile control at run timeThe Mobile controls behave the same way as other ComponentOne controls when they are created at run time and not placed on the form at design time. Because the IDE does not have an opportunity to obtain a run-time license on its own in this case, it is necessary to force the IDE to include a run-time license. To accomplish this, include at least one instance of the control on a form in the assembly that is instantiated BEFORE the dynamically created instance is created. Once a control of the same type is licensed, all others on the form are accepted as licensed.

    TroubleshootingWe try very hard to make the licensing mechanism as unobtrusive as possible, but problems may occur for a number of reasons.

    Below is a description of the most common problems and their solutions.

    I have a licensed version of a ComponentOne product but I still get the splash screen when I run my project.

    If this happens, there may be a problem with the licenses.licx file in the project. It either doesn't exist, contains wrong information, or is not configured correctly.

    First, try a full rebuild (Rebuild All from the Visual Studio Build menu). This will usually rebuild the correct licensing resources.

    If that fails follow these steps:

    1. Open the project and go to the Solution Explorer window.

    2. Click the Show All Files button on the top of the window.

    3. Find the licenses.licx file and open it. If prompted, continue to open the file.

    4. Change the version number of each component to the appropriate value. If the component does not appear in the file, obtain the appropriate data from another licenses.licx file or follow the alternate procedure following.

    5. Save the file, then close the licenses.licx tab.

    6. Rebuild the project using the Rebuild All option (not just Rebuild).

    Alternatively, follow these steps:

    1. Open the project and go to the Solution Explorer window.

    2. Click the Show All Files button on the top of the window.

    3. Find the licenses.licx file and delete it.

    4. Close the project and reopen it.

    5. Open the main form and add an instance of each licensed control.

    6. Check the Solution Explorer window, there should be a licenses.licx file there.

    7. Rebuild the project using the Rebuild All option (not just Rebuild).

    For ASP.NET 2.x applications, follow these steps:

    1. Open the project and go to the Solution Explorer window.

    2. Find the licenses.licx file and right-click it.

  • 12

    3. Select the Rebuild Licenses option (this will rebuild the App_Licenses.licx file).

    4. Rebuild the project using the Rebuild All option (not just Rebuild).

    I have a licensed version of a ComponentOne product on my web server but the components still behave as unlicensed.

    There is no need to install any licenses on machines used as servers and not used for development.

    The components must be licensed on the development machine, therefore the licensing information will be saved into the executable (.exe or .dll) when the project is built. After that, the application can be deployed on any machine, including web servers.

    For ASP.NET 2.x applications, be sure that the App_Licenses.dll assembly created during development of the application is deployed to the bin application bin directory on the web server.

    If your ASP.NET application uses WinForms user controls with constituent licensed controls, the runtime license is embedded in the WinForms user control assembly. In this case, you must be sure to rebuild and update the user control whenever the licensed embedded controls are updated.

    I downloaded a new build of a component that I have purchased, and now I'm getting the splash screen when I build my projects.

    Make sure that the serial number is still valid. If you licensed the component over a year ago, your subscription may have expired. In this case, you have two options:

    Option 1 - Renew your subscription to get a new serial number.

    If you choose this option, you will receive a new serial number that you can use to license the new components (from the installation utility or directly from the About Box).

    The new subscription will entitle you to a full year of upgrades and to download the latest maintenance builds directly from http://prerelease.componentone.com/.

    Option 2 Continue to use the components you have.

    Subscriptions expire, products do not. You can continue to use the components you received or downloaded while your subscription was valid.

    Technical SupportComponentOne offers various support options. For a complete list and a description of each, visit the ComponentOne Web site at http://www.componentone.com/Support.

    Some methods for obtaining technical support include:

    Online Support via HelpCentralComponentOne HelpCentral provides customers with a comprehensive set of technical resources in the form of FAQs, samples, Version Release History, Articles, searchable Knowledge Base, searchable Online Help and more. We recommend this as the first place to look for answers to your technical questions.

    Online Support via our Incident Submission FormThis online support service provides you with direct access to our Technical Support staff via an online incident submission form. When you submit an incident, you'll immediately receive a response via e-mail confirming that you've successfully created an incident. This email will provide you with an Issue Reference ID and will provide you with a set of possible answers to your question from our Knowledgebase. You will receive a response from one of the ComponentOne staff members via e-mail in 2 business days or less.

    Peer-to-Peer Product Forums and NewsgroupsComponentOne peer-to-peer product forums and newsgroups are available to exchange information, tips, and techniques regarding ComponentOne products. ComponentOne sponsors these areas as a forum for

  • 13

    users to share information. While ComponentOne does not provide direct support in the forums and newsgroups, we periodically monitor them to ensure accuracy of information and provide comments when appropriate. Please note that a ComponentOne User Account is required to participate in the ComponentOne Product Forums.

    Installation IssuesRegistered users can obtain help with problems installing ComponentOne products. Contact technical support by using the online incident submission form or by phone (412.681.4738). Please note that this does not include issues related to distributing a product to end-users in an application.

    DocumentationComponentOne documentation is installed with each of our products and is also available online at HelpCentral. If you have suggestions on how we can improve our documentation, please email the Documentation team. Please note that e-mail sent to the Documentation team is for documentation feedback only. Technical Support and Sales issues should be sent directly to their respective departments.ComponentOne documentation is available with each of our products in HTML Help, Microsoft Help 2.0 (WPF, .NET, ASP.NET and Mobile Device products only), and NetHelp format. The NetHelp version of the documentation is also available on HelpCentral. If you have suggestions on how we can improve our documentation, please email the Documentation team. Please note that e-mail sent to the Documentation team is for documentation feedback only. Technical Support and Sales issues should be sent directly to their respective departments.

    Note: You must create a ComponentOne Account and register your product with a valid serial number to obtain support using some of the above methods.

    Redistributable FilesComponentOne TreeView for ASP.NET is developed and published by ComponentOne LLC. You may use it to develop applications in conjunction with Microsoft Visual Studio or any other programming environment that enables the user to use and integrate the control(s). You may also distribute, free of royalties, the following Redistributable Files with any such application you develop to the extent that they are used separately on a single CPU on the client/workstation side of the network:

    C1.Web.UI.2.dll

    C1.Web.UI.Controls.2.dll

    C1.Web.UI.3.dll

    C1.Web.UI.Controls.3.dll

    Site licenses are available for groups of multiple developers. Please contact [email protected] for details.

    About This DocumentationAcknowledgements

    Microsoft, Windows, Windows Vista, and Visual Studio are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

    Firefox is a registered trademark of the Mozilla Foundation.Safari is a registered trademark of Apple Inc.

    ComponentOne

    If you have any suggestions or ideas for new features or controls, please call us or write:

    Corporate Headquarters

  • 14

    ComponentOne LLC 201 South Highland Avenue 3rd Floor Pittsburgh, PA 15206 USA 412.681.4343 412.681.4384 (Fax)

    http://www.componentone.com

    ComponentOne Doc-To-Help

    This documentation was produced using ComponentOne Doc-To-Help Enterprise.

    NamespacesNamespaces organize the objects defined in an assembly. Assemblies can contain multiple namespaces, which can in turn contain other namespaces. Namespaces prevent ambiguity and simplify references when using large groups of objects such as class libraries.

    The general namespace for ComponentOne Web products is C1.Web.UI.ControlsThe following code fragment shows how to declare a C1Menu (which is one of the core Studio for ASP.NET classes) using the fully qualified name for this class:

    Visual BasicDim menu As C1.Web.UI.Controls.C1Menu

    C#C1.Web.UI.Controls.C1Menu menu;

    Namespaces address a problem sometimes known as namespace pollution, in which the developer of a class library is hampered by the use of similar names in another library. These conflicts with existing components are sometimes called name collisions.

    Fully qualified names are object references that are prefixed with the name of the namespace where the object is defined. You can use objects defined in other projects if you create a reference to the class (by choosing Add Reference from the Project menu) and then use the fully qualified name for the object in your code.

    Fully qualified names prevent naming conflicts because the compiler can always determine which object is being used. However, the names themselves can get long and cumbersome. To get around this, you can use the Imports statement (using in C#) to define an alias an abbreviated name you can use in place of a fully qualified name. For example, the following code snippet creates aliases for two fully qualified names, and uses these aliases to define two objects:

    Visual BasicImports C1Menu = C1.Web.UI.Controls.C1MenuewImports MyMenu = MyProject.Objects.C1MenuDim wm1 As C1MenuDim wm2 As MyMenu

    C#using C1Menu = C1.Web.UI.Controls.C1Menu;using MyMenu= MyProject.Objects.C1Menu;C1Menu wm1;MyMenu wm2;

    If you use the Imports statement without an alias, you can use all the names in that namespace without qualification provided they are unique to the project.

  • 15

    Creating an AJAX-Enabled ASP.NET ProjectComponentOne TreeView for ASP.NET requires you to create an ASP.NET AJAX-Enabled project so that Microsoft ASP.NET AJAX Extensions and a ScriptManager control are included in your project before the C1TreeView control is placed on the page. This allows you to take advantage of ASP.NET AJAX and certain features such as partial-page rendering and client-script functionality of the Microsoft AJAX Library.

    When creating AJAX-Enabled ASP.NET projects, Visual Studios 2008 and 2005 both give you the option of creating a Web site project or a Web application project. MSDN provides detailed information on why you would choose one option over the other.

    If you are using Visual Studio 2008 with .NET Framework 2.0 or .NET Framework 3.0 or if you are using Visual Studio 2005, you must install the ASP.NET AJAX Extensions 1.0, which can be found at http://ajax.asp.net/. Additionally for Visual Studio 2005 users, creating a Web application project requires installation of a Visual Studio 2005 update and add-in, which can be found at http://msdn.microsoft.com/; however, if you have Visual Studio 2005 SP1, Web application project support is included and a separate download is not required.

    If you are using Visual Studio 2008 and .NET Framework 3.5, you can easily create an AJAX-enabled ASP.NET project without installing separate add-ins because the framework has a built-in AJAX library and controls.

    Note: If you are using Visual Studio 2010, see http://www.asp.net/ajax/ for more information on creating an AJAX-Enabled ASP.NET Project.

    The following table summarizes the installations needed:

    Visual Studio Version Additional Installation Requirements

    Visual Studio 2008, .NET Framework 3.5 None

    Visual Studio 2008 and .NET Framework 2.0 or 3.0

    Visual Studio 2005 Service Pack 1

    ASP.NET AJAX Extensions 1.0

    http://www.asp.net/ajax/downloads/archive/

    Visual Studio 2005 ASP.NET AJAX Extensions 1.0

    Visual Studio update and add-in (2 installs for Web application project support)

    The following topics explain how to create both types of projects in Visual Studio 2008 and 2005.

    Creating an AJAX-Enabled Web Site Project in Visual Studio 2008

    To create a Web site project in Visual Studio 2008, complete the following steps:

    1. From the File menu, select New | Web Site. The New Web Site dialog box opens.

    2. Select .NET Framework 3.5 or the desired framework in the upper right corner. Note that if you choose .NET Framework 2.0 or 3.0, you must install the extensions first.

    3. In the list of templates, select AJAX 1.0-Enabled ASP.NET 2.0 Web Site.

    4. Click Browse to specify a location and then click OK.

    Note: The Web server must have IIS version 6 or later and the .NET Framework installed on it. If you have IIS on your computer, you can specify http://localhost for the server.

    A new AJAX-Enabled Web Site is created at the root of the Web server you specified. In addition, a new Web Forms page called Default.aspx is displayed and a ScriptManager control is placed on the

  • 16

    form. The ScriptManger is needed to enable certain features of ASP.NET AJAX such as partial-page rendering, client-script functionality of the Microsoft AJAX Library, and Web-service calls.

    Creating an AJAX-Enabled Web Application Project in Visual Studio 2008

    To create a new Web application project in Visual Studio 2008, complete the following steps.

    1. From the File menu, select New | Project. The New Project dialog box opens.

    2. Select .NET Framework 3.5 or the desired framework in the upper right corner. Note that if you choose .NET Framework 2.0 or 3.0, you must install the extensions first.

    3. Under Project Types, choose either Visual Basic or Visual C# and then select Web. Note that one of these options may be located under Other Languages.

    4. Select AJAX 1.0-Enabled ASP.NET 2.0 Web Application from the list of Templates in the right pane.

    5. Enter a URL for your application in the Location field and click OK.

    Note: The Web server must have IIS version 6 or later and the .NET Framework installed on it. If you have IIS on your computer, you can specify http://localhost for the server.

    A new Web Forms project is created at the root of the Web server you specified. In addition, a new Web Forms page called Default.aspx is displayed and a ScriptManager control is placed on the form. The ScriptManger is needed to enable certain features of ASP.NET AJAX such as partial-page rendering, client-script functionality of the Microsoft AJAX Library, and Web-service calls.

    Creating an AJAX-Enabled Web Site Project in Visual Studio 2005

    To create a Web site project in Visual Studio 2005, complete the following steps:

    1. From the File menu in Microsoft Visual Studio .NET, select New Web Site. The New Web Sitedialog box opens.

    2. Select ASP.NET AJAX-Enabled Web Site from the list of Templates.

    3. Enter a URL for your site in the Location field and click OK.

    Note: The Web server must have IIS version 6 or later and the .NET Framework installed on it. If you have IIS on your computer, you can specify http://localhost for the server.

    A new Web Forms project is created at the root of the Web server you specified. In addition, a new Web Forms page called Default.aspx is displayed and a ScriptManager control is placed on the form. The ScriptManger is needed to enable certain features of ASP.NET AJAX such as partial-page rendering, client-script functionality of the Microsoft AJAX Library, and Web-service calls.

    Creating an AJAX-Enabled Web Application Project in Visual Studio 2005

    To create a new Web application project in Visual Studio 2005, complete the following steps.

    1. From the File menu in Microsoft Visual Studio 2005, select New Project. The New Project dialog box opens.

    2. Under Project Types, choose either Visual Basic Projects or Visual C# Projects. Note that one of these options may be located under Other Languages.

    3. Select ASP.NET AJAX-Enabled Web Application from the list of Templates in the right pane.

    4. Enter a URL for your application in the Location field and click OK.

  • 17

    Note: The Web server must have IIS version 6 or later and the .NET Framework installed on it. If you have IIS on your computer, you can specify http://localhost for the server.

    5. A new Web Forms project is created at the root of the Web server you specified. In addition, a new Web Forms page called Default.aspx is displayed and a ScriptManager control is placed on the form. The ScriptManger is needed to enable certain features of ASP.NET AJAX such as partial-page rendering, client-script functionality of the Microsoft AJAX Library, and Web-service calls.

    Adding the C1TreeView Component to a ProjectWhen you install ComponentOne Studio for ASP.NET, the Create a ComponentOne Visual Studio Toolbox Tab check box is checked, by default, in the installation wizard. When you open Visual Studio, you will notice a ComponentOne Studio for ASP.NET Projects tab containing the ComponentOne controls that have automatically been added to the Toolbox.

    If you decide to uncheck the Create a ComponentOne Visual Studio Toolbox Tab check box during installation, you can manually add ComponentOne controls to the Toolbox at a later time.

    To use C1TreeView, add the C1TreeView control to the form or add a reference to the C1.Web.UI.Controls.C1TreeView assembly in your project.

    Manually Adding the Studio for ASP.NET controls to the Toolbox

    When you install ComponentOne Studio for ASP.NET, the following C1TreeView component will appear in the Visual Studio Toolbox customization dialog box:

    C1TreeView

    To manually add the TreeView for ASP.NET control to the Visual Studio Toolbox:

    1. Open the Visual Studio IDE (Microsoft Development Environment). Make sure the Toolbox is visible (select Toolbox in the View menu if necessary) and right-click it to open the context menu.

    2. To make the C1TreeView component appear on its own tab in the Toolbox, select Add Tab from the context menu and type in the tab name, C1TreeView, for example.

    3. Right-click the tab where the component is to appear and select Choose Items from the context menu. The Choose Toolbox Items dialog box opens.

    4. In the dialog box, select the .NET Framework Components tab. Sort the list by Namespace (click the Namespace column header) and check the check boxes for the C1TreeView component belonging to namespace C1.Web.UI.Controls.C1TreeView.

    5. Click OK to close the dialog box.

    The C1TreeView control is added Visual Studio Toolbox.

    Adding C1TreeView to the Form

    To add C1TreeView to a form:

    1. Add it to the Visual Studio toolbox.

    2. Double-click each control or drag it onto your form.

    Adding a Reference to the Assembly

    To add a reference to the C1.Web.UI.Controls.C1TreeView assembly:

    1. Select the Add Reference option from the Website menu of your Web Site project or from the Project menu of your Web Application project.

    2. Select the most recent version of the ComponentOne Studio for ASP.NET assembly from the list on the NET tab or browse to find the C1.Web.UI.Controls.2.dll file and click OK.

  • 18

    3. Select the Form1.vb tab or go to View|Code to open the Code Editor. At the top of the file, add the following Imports directive (using in C#):Imports C1.Web.UI.Controls.C1TreeView

    Note: This makes the objects defined in the C1.Web.UI.Controls.2 assembly visible to the project. See Namespaces (page 14) for more information.

    Key FeaturesC1TreeView consists of the following main features:

    CSS Styling

    C1TreeView includes CSS supported styling so that you can use cascading style sheets to easily style the C1TreeView control to match the design of your current Web site.

    Visual Styles

    C1TreeView provides several built-in themes, known as visual styles, that can be easily applied through the C1TreeView Tasks menu or they can be modified to create a new visual style. For more information on the visual styles, see Visual Styles (page 50).

    Templates

    Use built-in template editing to change how the C1TreeView control appears. Templates allow you to easily add your own elements including text, images, and controls such as buttons to various nodes. See Templates (page 52) for more information.

    Design-time Support

    C1TreeView includes extensive design-time support, such as built-in designers and editors, so that you can create and customize the C1TreeView control with little or no code. See C1TreeView Smart Tag (page 28) and TreeView Designer Form (page 32) for more information.

    Data Binding

    Bind the C1TreeView control to a data source you can bind to an XMLDataSource or SiteMapDataSource, or you can even read data from AccessDataSource and create the C1TreeViewhierarchy dynamically. See Binding C1TreeView to an XML File (page 23) for more information on how to bind an XMLDataSource to the C1TreeView control.

    Animation Effects

    C1TreeView includes built-in animation effects for the expanded and collapsed nodes in the C1TreeView. You can specify the type of animation for the C1TreeView by setting the CollapseAnimation or

  • 19

    ExpandAnimation properties. See the Animation (page 42) topic for more information on C1TreeViews animation effects.

    Keyboard Support

    Add access key support to give the C1TreeView control focus with a chosen key combination. At run time users can use the keyboard arrow keys to navigate through the node items and the ENTER key to open a link in a node item.

    AJAX Support

    Built-in AJAX support lets users interact with C1TreeView without the control performing a postback operation back to the server.

    Set Postbacks

    Use the AutoPostBack property to determine whether C1TreeView should perform a postback to the server each time the end user interacts with the control.

    Browser Support

    C1TreeView includes support for the Internet Explorer (6.0 or later), Firefox (2 or later), and Safari Web browsers.

    XHTML Compliant

    C1TreeView provides complete XHTML compliance. The output that is generated is fully XHTML 1.1 compliant.

    Client-Side Object Model

    The C1TreeView control's client-side object model is exposed so that you can easily customize the control with client-side script. See Client-Side TreeView (page 52) for more information.

    Draggable nodes

    Drag and drop nodes into different locations. See Drag and Drop Nodes (page 47) for more information.

    Multiple node selection

    You can easily select multiple nodes in C1TreeView by holding the CTRL key while clicking nodes. See Node Selection (page 48) for more information on selecting multiple nodes.

    Check box support

    Node items can be implemented as regular check boxes which can be selected or unselected. See Check Boxes (page 46) for more information.

    Node editing

    Node editing allows node items to be edited at run time by setting the AllowEdit property to true.

  • 20

    TreeView for ASP.NET Quick StartIn this quick start you will learn how to create a root and child items for the C1TreeView control, apply a visual style, drag-and-drop treeview nodes, enable check boxes, and bind to an XMLDataSource.

    Adding C1TreeView to the PageIn this lesson you will learn how to create a new ASP.NET AJAX-Enabled Web site and add a C1TreeViewcontrol to your project.

    To begin the Quick Start, complete the following steps:

    1. Begin by creating a new ASP.NET AJAX-Enabled Web Site. Note that as you've created an AJAX-Enabled Web site, a ScriptManager control initially appears on the page.

    2. While in Design view navigate to the Visual Studio Toolbox and double-click the C1TreeView icon to add the C1TreeView control to your page.

    The page will appear similar to the following:

    Creating a TreeView Using the DesignerThis lesson will show you how to create root and child nodes, apply a visual style, and display check boxes next to the nodes.

    1. Select the C1TreeView control and click on the smart tag to open its Tasks menu.

    2. Select Edit TreeView from C1TreeView Tasks menu to open the designer.

    3. Right-click on the C1TreeView item and select Add Child | C1TreeView Node to add the root to the C1TreeView control. Set the C1TreeViewNode1's Text property to "Book List".

  • 21

    4. Right-click on Book List and select Add Child to create a child for the root node. Repeat this two more times. Three child nodes will exist under the Book List.

  • 22

    5. Select the first node under the Book List and set its Text property to "Language Books".

    6. Select the second node under the Book List and set its Text property to "Security Books".

    7. Select the third node under the Book List and set its Text property to "Classic Books".

    8. Right-click on the Classic Books node and select Add Child to create a child for the Classic Books node. Repeat this to create two C1TreeViewNodes under the Classic Books node.

    9. Select the first node under the Classic Books node and set its Text property to "The Great Gatsby".

    10. Select the second node under the Classic Books node and set its Text property to "Catch-22".

    11. Right-click on Book List and select Add Child to add to add a child node.

    12. Save and run your project and observe the following:

    The root node, Book List, isn't expanded since the Expanded property was set to False, by default.

    Expand the Book List and notice the child nodes you created.

    Notice the visual style is the default visual style.

    13. Go back to your project in the design view and open the TreeView Designer Form.

    14. Select the C1TreeView item and set the VisualStyle property to Vista.

    15. Save and run your project and notice the visual style, Vista, is applied to C1TreeView.

    16. Go back to your project in the Design view and open the TreeView Designer Form.

    17. Select the C1TreeView item and in the Properties window, set its behavior properties to the following:

    AllowDragDrop to True

    ShowCheckBoxes to True

    18. Click OK to save and close the designer.

    19. Run the project and observe the following:

  • 23

    Expand the Book List node and notice the check boxes next to each treeview node.

    Select any of the treeview nodes and drag it to a new location.

    Binding C1TreeView to an XML FileThis lesson shows you how to create an XML file through Visual Studio 2005 installed templates, add the XML Data Source component to the Web site, assign it to the C1TreeView control, and then set the binding for the C1TreeView.

    The final application will appear similar to the following at run time:

    To create an XML file, add the XMLDataSource component to the Web site, and then assign it to the C1TreeView control.

    1. Start a new Web site project.

    2. Create a new Img folder in your project and copy the images from the Control Explorer Sample project located in ControlExplorer\C1TreeView\Img to your new Img folder.

    Note: You may need to save and close your project and reopen it again for new img folder with the graphics to appear.

    3. Right-click on the App_Data in the Solution Explorer and select Add New Item. The Add New Itemdialog box appears.

    4. Select the XML File and rename it "treeview_structure.xml". The XML file will open.

    5. In the XML view, add the following data to the treeview_structure.xml replacing C1TreeView in each ImgUrlNode with the name of your project:

  • 24

    Note: Notice how the tags are indented for the child items.

    6. Switch back to the .aspx page and select the Design tab to switch to Design view.

    7. Expand the Data node in the Visual Studio Toolbox and add the XmlDataSource component to the Web page using a drag-and-drop operation.

    8. Right-click on the XmlDataSource control and select Properties to view its properties in the Properties window.

    9. In the Properties window, click on the ellipsis button next to the DataFile property to open the Select XML File dialog box. In the right pane, select the treeview_structure.xml file. Click OK to add it to the XmlDataSource1.DataFile property.

    10. In the Properties window, set the XmlDataSource1.Xpath property to "root/treeviewnode".

    11. Double-click on the C1TreeView control from the Visual Studio Toolbox to add it to your page.

    12. Open the C1TreeView control's C1TreeView Tasks menu and select XmlDataSource1 from the Choose Data Source drop-down listbox

    13. Click on the Source tab to switch to your source page and add the following DataBinding tags within the C1TreeView tags.

    Note: Two key properties are the DataMember and TextField properties. The DataMember sets the data member from the XML file to bind to the C1TreeView. The TextField gets the value of the Text property of a C1TreeViewNode object to which the C1TreeViewNodeBinding object is applied.

    14. Toggle back to the Design view and select Edit Bindings from the C1TreeView Tasks menu. The Bindings Collection Editor appears.

    15. Select treeviewnode in the pane to show the binding properties for the C1TreeViewNode.

  • 25

    Notice the DataMember, treeviewnode, is added to the C1TreeViewNodeBindingCollection and the C1TreeViewNodeBinding properties appear in the property grid so you can easily modify the settings for the treeviewnode object.

    16. Close the Bindings Collection Editor dialog box.

    17. Select the C1TreeView control and in the Properties window set the ShowCheckBoxes property to True.

    18. Save and build your project. Observe that the data from the treeview_structure.xml file is reflected in theC1TreeView control, and looks similar to the following at run time:

    TreeView for ASP.NET Top TipsThe following top tips for TreeView for ASP.NET will help you when you use the C1TreeView control.

    Tip 1: Use the AutoCollapse property to automatically collapse nodes that are not on the path of the currently expanded node.

    Setting the AutoCollapse property to True will automatically collapse nodes that are not on the path of the currently expanded node.

    Tip 2: Use the AllowTriState property of C1TreeView to enable tri-state checkboxes.

  • 26

    The CheckState property has three values: Checked, UnChecked and Indeterminate. If AllowTriState is set to True and a node of C1Treeview has child nodes, its CheckState is determined by the CheckState of its children. There are three cases which are as follows:

    Case 1: All Checked property of child nodes are set to true, then the parent nodes Checked property would be true and the CheckState is being set to Checked automatically.

    Case 2: Part of childnodes Checked property are set to true, then the parent nodes Checked property will be true, but the CheckState property will be Indeterminate.

    Case 3: All childnodess Checked properties are set to false, then the parent nodes Checked property will be false, and the Checkstate property will be UnChecked.

    Tip 3: Using AllowDragDrop property, OnClientNodeDragStarted and OnClientNodeDropped events to control DragDrop operation.

    When the AllowDragDrop property is set to True, the C1TreeViewNode will be allowed to drag and drop.

    The sample is for demonstrating the drag-and-drop function of C1TreeView. By using the events, only TreeView2's child node can be dragged and dropped only to TreeView1's 2nd level.

    Sample Script

    function C1TreeView2_OnClientNodeDragStarted(sender, eventArgs) {

    //to specified which kind of C1TreeViewNode can be drag.//it can use level of C1TreeViewNode,id,text or etc..

    if (eventArgs.get_node().get_level() == 0) {eventArgs.set_canceled(true);alert("can't drag root node.");

    }};

    function C1TreeView1_OnClientNodeDropped(sender, eventArgs) {//to specified which kind of C1TreeViewNode can be dropped.

    var dropped = true; if (eventArgs.get_desObj().get_owner() == null) {

    //treeview.dropped = false;

    }else {

    if (eventArgs.get_desObj().get_level() > 0) {dropped = false;

    }}

    if (!dropped) {eventArgs.set_canceled(true);alert("only drop to 2nd level.");

    }};

    function C1TreeView1_OnClientNodeDragStarted(sender, eventArgs) {//to cancel the drag event,use this to prevent dragging

    C1TreeView's node//and it can add dropped node.

    eventArgs.set_canceled(true);};

  • 27

  • 28

    Tip 4: Improving your applications page load performance.

    To improve your applications page load performance, set the Expanded property to False.

    Design-Time SupportThe following sections describe how to use C1TreeView's design-time environment to configure the C1TreeView control.

    C1TreeView Smart TagThe C1TreeView control includes a smart tag in Visual Studio. A smart tag represents a short-cut tasks menu that provides the most commonly used properties in C1TreeView.

    The C1TreeView control provides quick and easy access to the TreeView Designer Form and common properties through its smart tag.

    To access the C1TreeView Tasks menu, click on the smart tag in the upper-right corner of the C1TreeViewcontrol. This will open the C1TreeView Tasks menu.

    The C1TreeView Tasks menu operates as follows:

  • 29

    Choose Data Source

    Clicking on the Choose Data Source item opens a drop-down list where you can choose an existing data source or select a new data source to bind to.

    Configure Data Source

    The Configure Data Source item only appears when C1TreeView is bound to an XML data source. Clicking on the Configure Data Source opens a dialog box where you can indicate the XML data file and transform file to use and specify an XPath expression.

    Refresh Schema

    The Refresh Schema item only appears when C1TreeView is bound to a data source. Clicking on the Refresh Schema item refreshes the designer schema applied by the data source.

    Edit TreeView

    Clicking on the Edit TreeView item opens the TreeView Designer Form where you can quickly configure C1TreeView's elements without having to scroll through its Properties window. Here you can add, remove, and re-order C1TreeViewNodes as well as set a variety of properties defining their appearance, behavior, and more. For more information on the TreeView Designer Form, see TreeView Designer Form (page 32).

    Edit DataBindings

    Clicking on the Edit Databindings item opens the Bindings Collection Editor dialog box where you can add and remove bindings and edit properties.

    VisualStylePath

    Displays the default path for the visual style.

    UseEmbeddedVisualStyles

    When the UseEmbeddedVisualStyles is selected it enables you to use the embedded visual styles.

    VisualStyle

    Clicking the VisualStyle drop-down arrow enables you to select from different built-in visual styles. See Visual Styles (page 50) for more information.

    About

    Clicking on the About item displays the About dialog box, which is helpful in finding the version number of Treeview for ASP.NET and online resources.

    Edit Templates

    Clicking on the Edit Templates item switches the C1TreeView control to Template Editing Mode:

    In Template Editing Mode, the C1TreeView Tasks menu appears with different options:

  • 30

    Display

    Selecting the Display drop-down arrow will open a list of template areas that can be customized:

    Select a template from this list to open that template to be edited.

    End Template Editing

    Clicking the End Template Editing item will end Template Editing Mode and return you to the main C1TreeView Tasks menu.

    C1TreeViewNodeBinding Collection EditorThe C1TreeView control includes a collection editor that allows you to add or remove databindings from the C1TreeViewNodeCollection, as well as specify binding properties.

    There are two ways to access the C1TreeViewNodeBinding Collection Editor:

    From the C1TreeView Tasks menu:

    1. Click the smart tag in the upper-right corner of the C1TreeView control to open the C1TreeView Tasksmenu.

    2. Select Edit databindings. The Bindings Collection Editor appears.

    From the TreeView Designer Form:

  • 31

    1. Click the smart tag in the upper-right corner of the C1TreeView control to open the C1TreeView Tasksmenu.

    2. Select Edit TreeView. The TreeView Designer Form appears.

    3. With the C1TreeView control selected, click the ellipsis button next to the DataBindings property. The C1TreeViewNodeBinding Collection Editor appears. This dialog box, although it appears slightly different, is essentially the same as and contains the same properties as the Bindings Collection Editor.

    C1TreeView Context MenuC1TreeView has additional commands available on the context menu that Visual Studio provides for all .NETand ASP.NET controls.

    Right-click anywhere on the C1TreeView control to display the C1TreeView context menu:

  • 32

    The context menu commands operate as follows:

    Edit TreeView

    Clicking on the Edit TreeView item opens the TreeView Designer Form where you can quickly configure C1TreeView's elements without having to scroll through its Properties window. Here you can add, remove, and re-order C1TreeViewNodes as well as set a variety of properties defining their appearance, behavior, and more. For more information on the TreeView Designer Form, see TreeView Designer Form (page 32).

    Edit DataBindings

    Clicking on the Edit Databindings item opens the Bindings Collection Editor dialog box where you can add and remove bindings and edit properties.

    Edit Templates

    Clicking on the Edit Templates item switches the C1TreeView control to Template Editing Mode.

    TreeView Designer FormThe TreeView Designer Form is C1TreeView's designer for editing its properties, as well as the C1TreeViewNode properties. The TreeView Designer Form is similar to the Properties window as it allows programmers to modify the control visually. However, it allows you to select a C1TreeViewNode, set its properties, manipulate the nodes, and then preview the appearance of the C1TreeView control, all within the form.

    In this topic you will become familiar with the TreeView Designer Form's design interface so you can use the commands within it to edit C1TreeView with minimal effort and time.

  • 33

    To open the TreeView Designer Form , click the C1TreeView smart tag and select the Edit TreeView link from the C1TreeView Tasks menu:

    Exploring the TreeView Designer FormThe TreeView Designer Form contains a menu, toolbar, Edit tab, Preview tab, and properties pane.

  • 34

    Edit Tab

    Click the Edit tab and select the C1TreeView control or the desired C1TreeViewNode for which you would like to manipulate or adjust the properties.

    Preview Tab

    Click the Preview tab for a preview of what the C1TreeView control will look like.

  • 35

    Properties Pane

    The TreeView Designer Form properties pane is almost identical to the Visual Studio Properties window. Simply select a C1TreeViewNode or the C1TreeView control and set the desired properties here.

    Command Buttons

    The command buttons are summarized in the following table:

    Button Description

    OK Clicking OK applies the new settings to the C1TreeView control.

    Cancel Clicking Cancel closes the TreeView Designer Form, cancelling the new settings and applying the default settings to the C1TreeView control.

    TreeView Designer Form MenuThe TreeView Designer Form menu contains the following menu items and subitems:

  • 36

    Menu Item Submenu Item Description

    Load from XML Load the formatting for a C1TreeView control from an .xml file.

    Save as XML Save the current formatting of the C1TreeView control to an .xml file.

    File

    Exit Closes the TreeView Designer Form.

    Insert Item Inserts a new C1TreeViewNode at the specified place in the list of nodes.

    Add Child Adds a new C1TreeViewNode as a child of the C1TreeView or of another C1TreeViewNode.

    Cut Cuts the selected C1TreeViewNode to be moved in the list of nodes.

    Copy Copies the selected C1TreeViewNode.

    Paste Pastes a C1TreeViewNode at the specified location in the list of nodes.

    Delete Removes the selected C1TreeViewNode.

    Edit

    Rename Allows you to change the name of the C1TreeViewNode.

    TreeView Designer Form ToolbarThe toolbar for the TreeView Designer Form appears like the following:

    The table below describes each button in the toolbar:

    Button Name Description

    Move Item Up Moves the selected C1TreeViewNode up in the list of nodes.

    Move Item Down Moves the selected C1TreeViewNode down in the list nodes.

    Move Item Left Moves the selected C1TreeViewNode to the left in the hierarchy.

    Move Item Right Moves the selected C1TreeViewNode to the right in the hierarchy.

    Add Child Item Inserts a C1TreeViewNode as a child of the C1TreeView control or of another C1TreeViewNode.

    Insert Item Inserts a C1TreeViewNode at the specified location in the list of nodes.

    Cut Cuts the selected C1TreeViewNode to be moved in the list of nodes.

    Copy Copies the selected C1TreeViewNode .

    Paste Pastes a C1TreeViewNode at the specified location in the list of nodes.

    Delete Removes the selected C1TreeViewNode.

  • 37

    TreeView StructureC1TreeView is a tree type Web control that displays a hierarchical tree structure. A tree structure is used to represent hierarchical data into a graphical form.

    A tree contains one or more elements where each element is a node. A node can be a parent, child, or leaf node. The description for each type of node is as follows:

    Parent node is a node that contains other nodes.

    Child node is a node that is contained by another node.

    Leaf node is a node that does not contain child nodes.

    Like the classic tree structure, the C1TreeView contains one or more nodes that consist of parent, child, and leaf nodes. The parent, child, and leaf nodes are referred as C1TreeViewNodes.

    C1TreeView is drawn like an inverted tree where the root appears first. The C1TreeView can contain one or more root nodes. If a node has child nodes it can be collapsed or expanded. The ShowExpandCollapse property allows nodes to be expanded or collapsed when set to true. Each node can have text and an image associated with it, may be edited, selected, or display check boxes depending upon the property settings for the C1TreeView and C1TreeViewNode objects. The tree node can be rendered as a hyperlink and have a URL associated with it.

    TreeView ElementsEach C1TreeView object includes customizable UI elements for the collapsed, expanded, and non-expanded elements/nodes as well as special vertical and horizontal lines in the tree. These elements are shown in the following image and described in the table below:

    Item Description

    Expand/Collapse image The expansion indicator image shown above is the built-in image used with the Default visual style. To use a different image for expanding, set the ExpandedImageUrl property to the path of the image. To use a different image for collapsing, set the CollapsedImageUrl to the path of the image. Note that if the CollapsedImageUrl or ExpandedImageUrl are not specified, the default expand/collapse image is used instead.

    Node image You can specify an image to display next to the node text by using the ImageUrl property.

    Node text The node text is the text that appears on the C1TreeViewNode object. The node text can behave like a hyperlink when the NavigateUrl property is set or like a button when the C1TreeViewNode is in selection mode. When an image and text are used for the C1TreeViwNode

  • 38

    the text appears to the right of the image.

    Checkbox Check boxes allow the user to select a node or multiple nodes at once which is helpful for interfaces like a newsgroup tree. To enable check boxes set the ShowCheckBoxes to True.

    Hierarchical lines The ShowLines property is useful when you would like to see the hierarchical relationship between the objects. By setting the ShowLines property to True you get a clear picture of the hierarchical relationship for each object.

    The following table describes C1TreeViewNode's main properties used to distinguish the node types:

    C1TreeViewNode Property Description

    Nodes Gets the C1TreeViewNodeCollection for the child nodes.

    Text Gets or sets the text displayed for this C1TreeViewNode.

    Value Gets or sets the value for the C1TreeViewNode.

    ShowCheckBoxes Allow the check box to be shown on the nodes.

    ShowLines Gets or sets a value indicating whether lines connecting child nodes to parent nodes are displayed.

    TreeView CreationC1TreeViewNodes can be defined on your page or user control by using any of the following methods:

    Static creation using declarative syntax

    Dynamic creation using a contructor to create new instances of the C1TreeViewNode class.

    Data source creation through binding C1TreeView to a SiteMapDataSource, XMLDataSource, or an AccessDataSource.

    Static TreeView CreationEach node in the Tree is represented by a name/value pair, defined by the text and value properties of treenode, repectively. The text of a node is rendered, whereas the value of a node is not rendered and is typically used as additional data for handling postback events.

    A static menu is the simplest way to create the treeview structure.

    You can use the TreeView Designer Form designer to build the treeview system or you can use declarative syntax in the .aspx file to specify the nodes.

    To display static C1TreeViewNodes using the designer, open the TreeView Designer Form and add C1TreeViewNodes to the parent. The properties for each C1TreeViewNode can be modified directly in the designer. For more information about the menu designer, see TreeView Designer Form (page 32).

    To display static C1TreeViewNodes using declarative syntax, first nest opening and closing tags between opening and closing tags of the C1TreeView control. Next, create the treeview structure by nesting elements between opening and closing tags. Each element represents a node in the control and maps to a C1TreeViewNode object.

    Declarative syntax can be used to define the C1TreeViewNodes inline on your page.

    For example:

  • 39

    Dynamic TreeView CreationDynamic treeviews can be created on the server side or client side. When creating dynamic treeview on the server side, use a constructor to dynamically create a new instance of the C1TreeViewNode class. For client-side, the CreateInstance constructor can be used to dynamically create a new instance of the C1TreeView control. For example the follow script creates a new C1TreeView control on the client side:

    var aTreeView = C1.Web.C1TreeView.createInstance ();document.body.appendChild(aTreeView.element);

    C1TreeView or C1TreeViewNode contructors can be used to create a new instance of the C1TreeView or C1TreeViewNode class. Once the nodes are created, they can be added to the Node collection of a new node or treeview.

    For example:

    Visual BasicProtected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    'create an instance of the class Dim treeView As New C1TreeView() PlaceHolder1.Controls.Add(treeView) If Not Page.IsPostBack Then

    Dim P As New C1TreeViewNode()

  • 40

    P.Text = "Products" P.Value = "PS" P.Expanded = True treeView.Nodes.Add(P) Dim Pr1 As New C1TreeViewNode() Pr1.Text = "Product 1" Pr1.Value = "Pr1" Pr1.Expanded = True P.Nodes.Add(Pr1) Dim Oview1 As New C1TreeViewNode() Oview1.Text = "Overview" Oview1.Value = "Oview1" Pr1.Nodes.Add(Oview1) Dim Down1 As New C1TreeViewNode() Down1.Text = "Downloads" Down1.Value = "Down1" Pr1.Nodes.Add(Down1) Dim Supp1 As New C1TreeViewNode() Supp1.Text = "Support" Supp1.Value = "Supp1" Pr1.Nodes.Add(Supp1)

    Dim Pr2 As New C1TreeViewNode() Pr2.Text = "Products 2" Pr2.Value = "Pr2" Pr2.Expanded = True P.Nodes.Add(Pr2) Dim Oview2 As New C1TreeViewNode() Oview2.Text = "Overview" Oview2.Value = "Oview2" Pr2.Nodes.Add(Oview2) Dim Down2 As New C1TreeViewNode() Down2.Text = "Downloads" Down2.Value = "Down2" Pr2.Nodes.Add(Down2) Dim Supp2 As New C1TreeViewNode()

    Supp2.Text = "Support" Supp2.Value = "Supp2"

    Pr2.Nodes.Add(Supp2)

    End If

    End Sub C#

    protected void Page_Load(object sender, EventArgs e){

    //create an instance of the classC1TreeView treeView = new C1TreeView();PlaceHolder1.Controls.Add(treeView);

  • 41

    if (!Page.IsPostBack){

    C1TreeViewNode P = new C1TreeViewNode();P.Text = "Products";P.Value = "PS";P.Expanded = true;treeView.Nodes.Add(P);

    C1TreeViewNode Pr1 = new C1TreeViewNode();Pr1.Text = "Product 1";Pr1.Value = "Pr1";Pr1.Expanded = true;P.Nodes.Add(Pr1);

    C1TreeViewNode Oview1 = new C1TreeViewNode();Oview1.Text = "Overview";Oview1.Value = "Oview1";Pr1.Nodes.Add(Oview1);

    C1TreeViewNode Down1 = new C1TreeViewNode();Down1.Text = "Downloads";Down1.Value = "Down1";Pr1.Nodes.Add(Down1);

    C1TreeViewNode Supp1 = new C1TreeViewNode();Supp1.Text = "Support";Supp1.Value = "Supp1";Pr1.Nodes.Add(Supp1);

    C1TreeViewNode Pr2 = new C1TreeViewNode();Pr2.Text = "Products 2";Pr2.Value = "Pr2";Pr2.Expanded = true;P.Nodes.Add(Pr2);

    C1TreeViewNode Oview2 = new C1TreeViewNode();Oview2.Text = "Overview";Oview2.Value = "Oview2";Pr2.Nodes.Add(Oview2);

    C1TreeViewNode Down2 = new C1TreeViewNode();Down2.Text = "Downloads";Down2.Value = "Dow