ASP.NET examples
Do not run this file locally
Run it from your (local) web server where is installed IIS and ASP.NET (1.0, 1.1 or 2.0).
The ASP.NET service program must have write access to /Examples/AspNetVB/Database.mdb file
To permit write access on Windows XP right click to file Database.mdb in My Computer,
select Properties -> Security -> Users and set Full control to Allow.
If you don't have Security item in Properties, run My Computer,
in menu select Tools - > Folder options -> View and uncheck Use simple file sharing option.
Visual Basic
Ajax
Asynchronous background (new style) communication with server.
Data are downloaded from or uploaded to server by JavaScript XmlHttpRequest object on background, without reloading/submitting the page content.
You can check from configuration menu option Auto update changes to server for immediate updates after edit/modify.
When debugging, you can set <treegrid ... Debug='3' ... > to see communication with server. It opens two new browser's windows. You can see XML data or ASP.NET error server returned.
Remember, in Ajax communication, the asp.net page must return only xml data, not any standard html tags like <html> or <!doctype>.
See documentation AJAX versus submit and also tutorial Identifying rows when uploading.
If you want to write your applications by Visual Studio .NET (2002,2003 or 2005) it is better to write ASP.NET web service application instead of standard web page to generate XML data source for TreeGrid.
Also remember that TreeGrid does not support standard <!DOCTYPE> tag generated by Visual studio, you need to remove it.
Ajax table with DataTable
Main file AjaxTableDataTable.html, support code AjaxTableDataTable.aspx
Layout file in TableDef.xml, data in database table "TableData".
The simplest demonstration of using ASP.NET and AJAX. It generates data from database table 1:1 including id. Also updates changes to database according/with id.
It uses .NET classes DataTable and OleDbDataAdapter to access database. It uses class XmlDocument to process and generate XML.
Ajax table with OleDbCommand
Main file AjaxTableSqlCommand.html, support code AjaxTableSqlCommand.aspx
Layout file in TableDef.xml, data in database table "TableData".
The simplest demonstration of using ASP.NET and AJAX. It generates data from database table 1:1 including id. Also updates changes to database according/with id.
It uses .NET classes OleDbCommand and OleDbDataReader to access database. It uses class XmlDocument to process XML, but generates XML as standard string.
Ajax table with framework
Main file AjaxTableFramework.html, support code AjaxTableFramework.aspx, framework code TreeGridFramework.aspx
Layout file in TableDef.xml, data in database table "TableData".
The same example as previous Ajax table but with using functions from TreeGrid ASP.NET Framework. Also shows using user parameters.
Ajax table using old ASP style
Main file AjaxTableFrameworkAspStyle.html, support code AjaxTableFrameworkAspStyle.aspx, framework code TreeGridFramework.aspx
Layout file in TableDef.xml, data in database table "TableData".
The same example as previous Ajax table with framework but uses old style page creating by direct code instead of use Page_Load event.
Ajax table with code behind
Main file AjaxTableCodeBehind.html, support code AjaxTableCodeBehind.aspx, code behind AjaxTableCodeBehind.aspx.vb
Layout file in TableDef.xml, data in database table "TableData".
The same example as Ajax table, but uses code excluded to .cs file by @Page Src attribute.
When using Visual Studio, you can use CodeBehind attribute instead of Src, but you need to compile the .cs file.
Remember, when using Visual Studio for Ajax, it is better to write ASP.NET web service application instead of standard web page to generate XML data source for TreeGrid, see next example.
Ajax table in ASP.NET web service
Main file AjaxTableDataTable.html, support code AjaxTableService.asmx
Layout file in TableDef.xml, data in database table "TableData".
The demonstration of ASP.NET web service that creates and processes TreeGrid XML data.
It is reccomended to use web services with Visual studio.
Ajax table with server side paging and export
Main file AjaxTablePaging.html, support codes AjaxTablePaging.aspx , AjaxTablePagingPage.aspx , AjaxTablePagingExport.aspx
Layout file in TableDef.xml, data in database table "TableData".
The same example as previous Ajax table but with using server paging and export routine.
The pages are downloaded on demand from server (when the page is visible by scrollbars).
It is simple example with ineffective database access - it loads all table for every page and throws the rest away.
It also simply reloads all body when rows are added or deleted instead of handling changes in pages.
Ajax tree with framework
Main file AjaxTreeFramework.html, support code AjaxTreeFramework.aspx, framework code TreeGridFramework.aspx
Layout file in TreeDef.xml, data in database table "TreeData".
Generates treetable from database table with column Parent where are relations Parents/Children. Parent column contains parent's id of the child. For root rows it contains "#Body", for fixed rows "#Head" or "#Foot".
Uploaded rows are still identified by preset and standardly generated id attributes.
Uses functions from TreeGrid ASP Framework.
Ajax Extended API with reloading
Main file AjaxAPI.html, support codes AjaxTableFramework.aspx and AjaxTreeFramework.aspx , framework code TreeGridFramework.aspx
Layout files in TableDef.xml and TreeDef.xml, data in database tables "TableData" and "TreeData".
It shows two tables from previous examples and demonstrates Extended API functions for reloading, changing data source when reloading, catching data event and so on.
Ajax grid
Main file AjaxGrid.html, support codes AjaxGridData.aspx , AjaxGridLayout.aspx , AjaxGridUpload.aspx
Data in database table "TableData".
Demonstrates advanced generating from and updating to database.
Generates treetable from standard database table. Also flips the table and shows data in changed layout.
For every action is used another support code (Layout, Data, Upload). The layout is also generated.
Rows are identified by one unique editable column, with using full ids (including parents ids).
For demonstration it shows id column, to see what ids are generated by TreeGrid.
Complete application - Schools
Main file Schools.html
Support codes Schools.aspx (main file generates data and also saves changes to database or adds new user),
SchoolsRatings.aspx (loads reviews for given record, used for server child paging),
SchoolsReview.aspx (saves one review to database, called as custom AJAX call).
Layout file in SchoolsDef.xml, data in database tables "Schools_Schools", "Schools_Ratings" and "Schools_Users".
Uses also file SchoolsStars.gif (
)
Complete application to demonstrate generating from and updating to different database tables with various structure. Demonstrates also server child paging feature (loading children on demand).
And also custom AJAX call.
The application show list of schools that can be sorted and filtered. The records can be added/deleted or modified by logged user or admin.
The records can be rated and reviewed by visitors.
Ajax and DLL
This ASP.NET example uses TreeGrid server library
Ajax DLL upon XML file and checking for updates
Main file AjaxServerDLLDisk.html, support code AjaxServerDLLDisk.aspx
Layout file in Data2Def.xml, data file in Data2.xml.
Demonstrates using server DLL upon static XML data file.
Also demonstrates sharing data among more clients and automatic updating client's data after data on server are modified by another client.
The ASP.NET service program must have write access to file /Examples/ServerDLL/Data2.xml !
Main examples - paging
To save changes the ASP.NET service program must have write access to /Examples/ServerDLL/tmp directory !
The main file ../ServerDLL/ServerDLL.html can be executed with various parameters:
- example - index of paging example (0 - 3);
this parameter only presets value in select box.
- paging - paging type,
0 - none, 1 - client, 2 - server;
this parameter only presets value in select box
- pages - display type, 0 - All pages visible, 1 - One page visible;
this parameter only presets value in select box
- rows - index of number of rows, 0 - 2000, 1 - 10000, 2 - 50000;
this parameter only presets value in select box
- style - style index, 0 - Standard, 1 - Light, 2 - Bigger, 3 - Game;
this parameter only presets value in select box
- src - URL of server side script used as data source, ignored if examples are run locally from file system.
The URL can be relative to Examples/ServerDLL/ url or can be absolute, if you need specify port for server (for example src=http://locahost:8084/php/AjaxServerDLL.aspx).
But remember, most browsers refuse to access sources from different server then the server where main page is running from.
- method - method of communication with server script,
Soap - soap communication, use it for web services, Form - standard submit, use it for web pages.
- formservice - set it to 1 if you want to test ASP.NET web services with method = Form.
For method Soap or any other sources let it at 0.
- format - data format, Internal - internal format, Dtd - DTD compatible format, not supported by TreeGrid.dll/so
- debug - level of displaying data sent to and got from server , 0 - no debug, 1 - only errors, 3 - all in two windows, 4 - all in all windows
Ajax server paging with DLL, simplified version
Main file ../ServerDLL/ServerDLL.html?src=../AspNetVB/AjaxServerDLLSimple.aspx
with JavaScript support code ../ServerDLL/ServerDLL.js.
ASP.NET support code AjaxServerDLLSimple.aspx uses ../../Server/TreeGrid.dll component (TreeGrid server library).
Uses file DataXZDef.xml as layout and DataXY.xml as data source.
Where X is example index and Y is rows index (0='S', 1='', 2='E'),
Z can be 'E' for server paging.
Remember, XML datafiles DataXE.xml for 50000 rows are not included in this distribution due their size and can be downloaded from www.treegrid.com/Download/DataE.zip.
Submit
Synchronous (old style) communication with server.
Data are included in page in hidden input. Changes are sent to server in the hidden input of submitted <form> on page.
See documentation AJAX versus submit and also tutorial Identifying rows when uploading.
Submit table with DataTable
Main file SubmitTableDataTable.aspx
Layout file in TableDef.xml, data in database table "TableData".
The simplest demonstration of using ASP.NET and standard page submit. It generates data from database table 1:1 including id. Also updates changes to database according/with id.
It uses .NET classes DataTable and OleDbDataAdapter to access database. It uses class XmlDocument to process and generate XML.
Submit table with OleDbCommand
Main file SubmitTableSqlCommand.aspx
Layout file in TableDef.xml, data in database table "TableData".
The simplest demonstration of using ASP.NET and standard page submit. It generates data from database table 1:1 including id. Also updates changes to database according/with id.
It uses .NET classes OleDbCommand and OleDbDataReader to access database. It uses class XmlDocument to process XML, but generates XML as standard string.
Submit table with framework
Main file SubmitTableFramework.html, framework code TreeGridFramework.aspx
Layout file in TableDef.xml, data in database table "TableData".
The same example as previous Submit table but with using functions from TreeGrid ASP.NET Framework. Also shows using user parameters.
Submit table using old ASP style
Main file SubmitTableFrameworkAspStyle.aspx, framework code TreeGridFramework.aspx
Layout file in TableDef.xml, data in database table "TableData".
The same example as previous Submit table with framework but uses old style page creating by direct code instead of use Page_Load event.
Submit table with code behind
Main file SubmitTableCodeBehind.aspx, code behind SubmitTableCodeBehind.cs
Layout file in TableDef.xml, data in database table "TableData".
The same example as Submit table, but uses code excluded to .cs file by @Page Src attribute.
When using Visual Studio, you can use CodeBehind attribute instead of Src, but you need to compile the .cs file.
Submit tree with framework
Main file SubmitTreeFramework.aspx, framework code TreeGridFramework.aspx
Layout file in TreeDef.xml, data in database table "TreeData".
Generates treetable from database table with column Parent where are relations Parents/Children. Parent column contains parent's id of the child. For root rows it contains "#Body", for fixed rows "#Head" or "#Foot".
Uploaded rows are still identified by preset and standardly generated id attributes.
Uses functions from TreeGrid ASP Framework.