Skip Navigation LinksHome > Products > AspxFormsGen 2.0 > Tutorial > Express Edition

AspxFormsGen Express/Standard Tutorial

AspxFormsGen Express Edition
  1. Let's us familiarize our self with the AdventureWorks Database. Open MS SQL Server 2005 Management Studio.
  2. Expand the databases node
  3. Make sure you have the AdventureWorks database (figure 1.)


    (Figure 1)

  4. Expand the Table node, notice that you have about 70 user tables (figure 2).


    (Figure 2)

  5. Note: The webforms that will be generated by AspxFormsGen will be based from these tables.
  6. Now let's open the AspxFormsGen Application (figure 3). (Note that you don't need MS SQL Server 2005 Management Studio open to operate AspxFormsGen)


    (Figure 3 )

  7. The first four textboxes (Server, Database, Username, Password) are needed to connect to the database. Here's a more detailed explanation:

    • Server: The name of the server where your MS SQl Server 2005 is installed. For most parts, if your Database is installed locally (this is our recommendation for this tutorial), the server name would be localhost.

    • Database: The name of the database that you want to make ASP.Net 2.0 webforms for, e.g. Northwind, Pubs, AdventureWorks.

    • Username: The username for the database that you're trying to access. Note: For this tutorial, you need a username that has "sysadmin" priviledges in the database.

    • Password: The password pair of the username above.

    • Directory: This is the directory in your computer where the generated webforms will be written to. If the directory you specify does not exist, a folder for that directory will be created. If the directory you specify has files that have the same names as the files that will be created, your files will be overwritten without notice. Note: Make sure that you have "write" permissions to this directory.

    • Language: The language where your webforms will be generated in. You have 2 options, C# 2.0 or VB.Net 2.0 (Visual Basic 8.0).

    • Create Stored Procedures: AspxFormsGen Professional Edition Only. When checked, generates Select, Insert, Update, and Delete stored procedures in the database. These stored procedures are automatically used as data sources for the generated data bound controls. When not checked, Ad Hoc SQL is generated in the web forms as data sources. Note: Generated stored procedures will overwrite existing stored procedures that has the same name, so make sure to use a stored procedure prefix that is different from the one that you're using now.

    • Stored Proc Prefix: AspxFormsGen Professional Edition Only. This is the prefix that is used when naming the generated stored procedures. E.g. "aspx_" will create as stored procedured named "aspx_StoredProcedureName". Note: We recommend that you use a prefix that is readily recognizable to you as one generated by AspxFormsGen.

    • GridView Style: AspxFormsGen Professional Edition Only. Generates a simple theme for the generated web forms based on the selected style. There are 8 styles to choose from.

  8. Fill out the Server. Since my server is local, "localhost" will do just fine.
  9. Fill out the Database name. Type "AdventureWorks".
  10. Fill out the Username. Use a user that has sysadmin rights. (Note: In figure 4 I'm using a user named "adventureworks" because I created a user in my local MS SQL Server 2005 named adventureworks). If you have an "sa" user then type this in.
  11. Fill out the Password. (Note: In figure 4, when I created a user in MS SQL Server 2005 named adventureworks, I assigned it a password "adventureworks"). If you're using the "sa" user, the password is probably blank.
  12. Used the default "C:\AspxFormsGen" as the Directory.
  13. Choose a Language. For this tutorial we're going to use C#.
  14. Click Submit. AspxFormsGen will start generating the files (figure 4).


    (Figure 4)

  15. Once webforms generation is complete, a message box will appear (figure 5). Click Ok. Then close AspxFormsGen by clicking the close button.


    (Figure 5)

  16. Now go to the C:\AspxFormsGen directory. For the Express Edition, notice that you have 141 objects in this directory (figure 6). About half of these objects are ASP.Net 2.0 Webforms (.aspx), and the other half are the respective code files (.aspx.cs or .aspx.vb). AspxFormsGen Express generated regular unbound webforms.

    For the Standard Edition, notice that you have approximately six times (6x) the number of objects as the Express Edition. It generated all the the unbound webforms the Express Edition would have generated, plus five times (5x) more Bound-Webforms.


    (Figure 6)

  17. Let's create a website in Visual Studio 2005 that will contain all these generated webforms.
  18. Open MS Visual Studio 2005.
  19. On the File Menu of Visual Studio 2005, click New Website (figure 7).


    (Figure 7)

  20. On the new website window, choose ASP.Net Website, on the Location choose FileSystem (default) and then type in "C:\Inetpub\wwwroot\AdventureWorks"), select Visual C# as the Language, then click ok (figure 8).


    (Figure 8)

  21. Visual Studio 2005 will create a new website. On the solution explorer you will notice that Visual Studio 2005 have created a "Default.aspx" file. Right click on it, then click Delete (figure 9).


    (Figure 9)

  22. Let's leave the Visual Studio 2005 IDE and go back to our desktop. Open both directories "C:\Inetpub\wwwroot\AdventureWorks" (directory for the newly created website) and "C:\AspxFormsGen" (directory where AspxFormsGen generated all our unbound webforms earlier) (figure 10).


    (Figure 10)

  23. Highlight all the objects in "C:\AspxFormsGen" and then drag it to the "C:\Inetpub\wwwroot\AdventureWorks" directory (figure 11).


    (Figure 11)

  24. Let's go back to the Visual Studio IDE. Right click on the website project "C:\...\AdventureWorks" in the solution explorer, then click Add Existing Item...(figure 12).


    (Figure 12)

  25. In the Add Existing Item window, select all objects except the App_Data folder. Then click the Add button (figure 13).


    (Figure 13)

  26. In the solution explorer you will notice that you have 70 webforms (for Express Edition, approximately 5x more for the Standard Edition) and their respective codefiles plus 1 html file was added to your website. Right click on the "Defautl.htm" file, then click Set As Start Page (figure 14).


    (Figure 14)

  27. Let's run the website by hitting the F5 function key on your keyboard. A Debbuging Not Enabled window will show up, just click ok (figure 15).


    (Figure 15)

  28. Now that your website is finally running you will notice that AspxFormsGen Express generated 70 unbound webforms with the Express Edition, or 70 unbound webforms plus approximately 350 bound webforms for the Standard Edition, for the AdventureWorks database. These webforms are shown as links in the Default.htm page. (figure 16).


    (Figure 16)

  29. Scroll down the page and navigate to the "ProductWebform.aspx". Things to note: (figure 17).

    • This webform is generated based on the Production.Product table of the AdventureWorks table.
    • Each column in the Production.Product table is shown on this webform.
    • The webform contains both RequiredFieldValidators and CompareValidators (for date and numbers).
    • The ForeignKey columns are pre-populated with data from their respective Foreign Key Table, e.g. Product Model ID.
    • Column names are used as control titles and are nicely separated with spaces, e.g. the SizeUnitMeasureCode (or if you have a column that's named: SIZE_MEASURE_UNIT_CODE, size_measure_unit_code, or [Size Measure Unit Code]) is shown as Size Unit Measure Code.
    • The webform controls are unbound (except the DropDownList controls, the AspxFormsGen Standard and Professional edition offers approximately 4 times the number of webforms. The additional webforms uses (GridViews, FormViews) Databound controls.), therefore, it won't do anything other than validate your inputs.
    • No page formatting is implemented (AspxFormsGen Professional Edition generates a simple theme that contains a simple skin file and a stylesheet file for the whole website).


    (Figure 17)

  30. Close the web browser and let's examine the generated code. Double-click ProductWebform.aspx in the solution explorer. Things to notice:

    • MaxLength is added to string column data types, e.g. Size has a MaxLength.
    • RequiredFieldValidators are added to None-nullable columns.
    • CompareValidators are added to Date and number columns.
    • Only the DropDownlist controls are data-bound
    • DropDownlist controls are used for columns that has explicit foreign relations with another table.
    • The DropDownlist controls are bound using SqlDataSource control.
    • SqlDataSource controls retrieves data for the DropDownlist using Ad-Hoc SQL (the AspxFormsGen Professional edition gives you the option to create stored procedures in your database instead of using Ad-Hoc SQL).

  31. For the Standard Edition, additional bound webforms were also created named for the same table in the database. For example the forms below were also generated along with the unbound webform that was created for the Express Edition for each of the tables in your database:

    • ProductWebform.aspx - unbound webform
    • ProductFormView.aspx - read-only bound webform
    • ProductFormViewAdd.aspx - insert record bound webform
    • ProductFormViewEdit.aspx - update record bound webform
    • ProductGrid.aspx - read-only bound webform with GridView control
    • ProductGridAdmin.aspx - bound webform with GridView control with (delete button, and edit link)

    The bound webforms are bound via Ad-Hoc SQL embedded in the generated SQLDataSource web control in each of the bound webforms.

  32. Let's look at the CodeFile for ProductWebform.aspx. Go back to the solution explorer, then right click on the ProductWebform.aspx, click "View Code". Things to notice:

    • No code written here.
    • A commented "Generated by AspxFormsGen" is shown on top of the page (AspxFormsGen Standard and Professional Editions does not have these comments)..

  33. You can go ahead and examine the rest of the bound webforms that was generated by the Standard Edition.
  34. You're done.