Server Events and Client Scripts

ASP.NET Maker now supports server events and client scripts. You can create your own functionality by writing your own customized server and client side codes. The customized codes are stored in your projects so you can migrate your project to other templates or future versions easily. This feature reduces the need of template customization and create maximum possibilities for you to customize and create more advanced features for your projects.

The steps to create the server events and client scripts are as follows:

After loading the database, the database objects (tables, views, custom views and reports) will be shown in the left pane (the database pane). Click on any table to go to the Field Setup Page and the Server Events and Client Scripts page at any time.

Note: For simplicity, we use "table" in the following description to refer to any of database object in the project. A database object can be either a table, a view, a custom view or a report.


The treeview shows the available server events and client scripts that you can add to your project:

Server Events Server-side VB/C# procedures

Global

The events are applicable to all pages.

Table-Specific

The set of events are table-specific, the events are applicable to the selected table only

Other

The events are applicable to some common pages in the project only
Client Scripts Client-side JavaScript

Global

The JavaScript are included in all pages with header and footer

Table-Specific

The JavaScript are table-specific, they are included to pages for the selected table only

Other

The JavaScript are included in some common pages in the project only

To add your custom scripts to the server events or client scripts, select an item in the treeview, then enter your code in the editor.

The editor supports Find and Replace. Press Ctrl-F to open the Find dialog and press Ctrl-H to open the Replace dialog.

You can click the [Reset] button to discard the existing code and reload template code for the server event or client script.

 

Code Repository

ASP.NET Maker now provides a Code Repository for easy reuse of your code across projects and sharing with other users. Click the [Code Repository] button to open it, categorized reusable code will be displayed:

You can add the code to the editor by clicking the [Add to Editor] button, or by double-clicking the item, or simply drag the item to the editor. The reusable code is stored in XML files which reside in s subfolder name "code" under the installation folder. The format of the XML files is simple, there are 3 parts:

  1. description - description of the reusable code
  2. code - code to be inserted to editor
  3. globalcode - common code to be inserted to Global Code (see below), this code will only be inserted once into the project. For example , if your code is used several times in your project and your code calls a helper function, it is unnecessary to include the helper function several times. In this case you put your helper function in the globalcode section, then the function will only be included one time.

There are a few example files in the "code" folder, you can copy and modify for your own code and then save them under the "code" folder for reuse.

 

Server Events

Note: Do not confuse ASP.NET Maker server events with ASP.NET's events, they are not the same. For example, ASP.NET Maker generated page has Page_Load and Page_Unload event, they are event for the page (such as a List page or a View page) for a table, they are not the Page_Load and Page_Unload events of the physical ASP.NET page (.aspx).

In general, server events are fired in the following order:

Page_Loading (Global) -> Page_Load (Table-Specific/Other) -> <Table>.RecordSet_* / Row_* (Table-Specific) -> Page_Unload (Table-Specific/Other) -> Page_Unloaded (Global)

Available server events are:

Global -> All Pages

Database_Connecting

This event will be called by all pages before connecting to the database. Note: This is a global function.

The argument is the connection string. You can use this event to change the connection string (e.g. changing connection info with server, or even connect to other databases).

Example

Public Sub Database_Connecting(ByRef Connstr As String)
    If ew_CurrentUserIP() = "127.0.0.1" Then ' Testing on local PC
        Connstr = "My connection string on localhost"
    End If
End Sub

Page_Loading

This event will be called by all pages at the beginning of the page. If the pages involves database connection, it will be called after connecting to the database and before the Page_Load event.

Page_Unloaded

This event will be called by all pages at the end of the page. If the pages involves database connection, it will be called before closing database connection and after the Page_UnLoad event.

Global Code

Server code to be included in all pages. This may contain your constants, variables and functions.

Note: The code will be generated as part of the base class of all (almost) pages, it should include shared members such as shared variables or shared methods only.

User_Validated

For use with security. (See Security Settings) This event is fired after successful user login. The user info is passed to the event as a DbDataReader, you can get more info of the user and use it as you need.

Note: This event is not fired for the hard-coded administrator.

Example

Add current user's country to session variable

' Note: This event is a Security class member, so you can refer to other members of the Security class directly
Public Sub User_Validated(rs As DbDataReader)
    HttpContext.Current.Session("UserCountry") = rs("Country")
End Sub

UserLevel_Loaded

For use with User Level security. (See Security Settings) This event is fired after successful user login and after the User Level settings are loaded. It is possible to do actions such as changing or adding User Level permissions.

Example

Change the permissions of an User Level for a table

' Note: This event is a Security class member, so you can refer to other members of the Security class directly
Public Sub UserLevel_Loaded()
    DeleteUserPermission("Sales", "Order", EW_ALLOW_ADD)
    AddUserPermission("Sales", "Order", EW_ALLOW_EDIT)
End Sub

MenuItem_Adding

This event is fired for custom menu items before it is added to the menu. The menu item info is passed to the event as an instance of the cMenuItem object, refer to aspxfn*.vb/cs for members of the object. Return False if you don't want to show the menu item.

Example

Only show a menu item after the user has logged in

Public Function MenuItem_Adding(ByRef Item As cMenuItem) As Boolean
    'Response.Write Item.AsString
    ' Return False if menu item not allowed

    If Item.Text = "Download" Then
        Return IsLoggedIn()
    Else
        Return True
    End If
End Function

TablePermission_Loading

For use with User Level security. (See Security Settings) This event is fired before the user permission for the table of the current page is loaded. It is possible to do actions such as changing or adding more User Level permissions to the current user.

Note: This is an event fired for the current table only. If you change the permissions of the other tables in this event, there will be no effect. Use the UserLevel_Loaded event if you need to change permissions of other tables.

Example

Grant another User Level to the user and let the user have permissions of more than one User Level for the current table.

' Note: This event is a Security class member, so you can refer to other members of the Security class directly
Public Sub TablePermission_Loading(Page As AspNetMakerPage)
    If CurrentUserName = "nancy" Then
        AddUserLevel("Manager")
    End If
End Sub

TablePermission_Loaded

For use with User Level security. (See Security Settings) This event is fired after the user permission for the table of the current page is loaded. It is possible to to change the permission by using the CanXXX properties of the Security class.

Note: This is an event fired for the current table only. If you change the permissions of the other tables in this event, there will be no effect. Use the UserLevel_Loaded event if you need to change permissions of other tables.

Example

Grant more permissions to the user and let the user have more permissions than his/her User Level allows for the current table.

' Note: This event is a Security class member, so you can refer to other members of the Security class directly
Public Sub TablePermission_Loaded(Page As AspNetMakerPage)
    If CurrentUserName = "nancy" And Page.TableName = "Orders" Then
        CanEdit = True
    End If
End Sub

UserID_Loading

For use with User ID security. (See Security Settings) This event is fired after successful user login and before loading the User ID and its child User IDs of the current user. These User IDs determine which records the current user can access. It is possible to do actions such as changing the User ID of the current user so the user can access records that he/she can access by its original User ID.

Example

Change the user's User ID to his parent user's user ID and let the user access more records (accessible by the parent user).

' Note: This event is a Security class member, so you can refer to other members of the Security class directly
Public Sub UserID_Loading()
    If CurrentParentUserID <> "" Then
        CurrentUserID = CurrentParentUserID
    End If
End Sub

UserID_Loaded

For use with User ID security. (See Security Settings) This event is fired after loading the User ID and its child User IDs of the current user. These User IDs determine which records the current user can access. It is possible to do actions such as adding or deleting the loaded User IDs for the current user so the user can access more or less records that he/she can access by its originally loaded User IDs.

Example

Add more User IDs to the user and let the user access more records

' Note: This event is a Security class member, so you can refer to other members of the Security class directly
Public Sub UserID_Loaded()
    If CurrentUserName = "nancy" Then
        AddUserID(GetUserIDByUserName("janet"))
    End If
End Sub

User_PasswordExpired

This event will be called if the user password is already expired. Arguments are user and pwd which are the username and expired password of the user.
Table-Specific -> Common (Note: These events are members of the table class)

RecordSet_Selecting

This event will be called before selecting records. Note: This event is a table class member. The argument of the event is the filter (part of the WHERE clause of the SQL) for selecting records, you can customize the filter to change the records to be selected.

Example

Add your own filter. Note that the filter may have value, append your filter to it, not replace it.

Public Sub Recordset_Selecting(ByRef filter As String)
    If filter <> "" Then filter = "(" & filter & ") AND "
    filter &= "(Field1 = 1234)" ' Add your own filter    
End Sub

RecordSet_Selected

This event will be called after selecting records. The argument is the recordset selected.

RecordSet_SearchValidated

This event will be called after the Form_CustomValidate event and the search criteria is assigned to the table/field objects. You can modify the search criteria in this event.

This event is a member of the table class. There is no arguments for this event. To change the Quick Search criteria, change the BasicSearchKeyword and BasicSearchType property of the table object. To change the Advanced Search criteria, change the AdvancedSearch property (which is an object of the cAdvancedSearch class) of the field object.

RecordSet_Searching

This event will be called before the search criteria is saved for the session.

This event is a member of the table class. The argument of the event is the part of WHERE clause built from the Quick/Extended Quick/Advanced search criteria. You can modify the WHERE clause in this event.

Row_Deleting

This event will be called before deleting a record. The argument of the event is the record deleted as OrderedDictionary object.

Row_Deleted

This event will be called after deleting a record. The argument of the event is the record deleted as OrderedDictionary object.

Example

Delete detail records

Public Sub Row_Deleted(rs As OrderedDictionary)
    Conn.Execute("DELETE * FROM MyDetailTable WHERE MyForeignKeyField=" & rs("ID"))
End Function

Row_Inserting

This event will be called before inserting a record. The argument of the event is the new record as OrderedDictionary object.

Example

Make sure a field value is valid

Public Function Row_Inserting(ByRef rs As OrderedDictionary) As Boolean
    If rs("Percentage") > 100 Then
        rs("Percentage") = 100
    End If
    ' To cancel, set return value to False
    Return True
End Function

Row_Inserted

This event will be called after inserting a record. The argument of the event is the new record as OrderedDictionary object.

Example

Get the ID (autoincrement field) of the just inserted record

Public Sub Row_Inserted(rs As OrderedDictionary)
    Page.Message = "The ID of the new record is " & rs("ID")    
End Sub

Row_Rendering

This event will be called before rendering (applying the View/Edit Tag settings) a record.

Row_Rendered

This event will be called after rendering a record.

This is an extremely useful event for conditional formatting, you can do a lot of things with this event, such as changing font color, font styles, row background color, cell background color, etc. by changing the table or field class properties in the event according to field values.

The table class has a RowAttrs property which is an hashtable of HTML attributes for the table row. The field class has CellAttrs, ViewAttrs and EditAttrs for the table cell, View Tag and Edit Tag of the field respectively. The keys of these hashtables must be valid HTML attributes for the HTML tag, always use lowercase for the keys. The attribute values will be outputted as double quoted attributes, so if you have double quotes in your values, try to use single quotes if possible, or use "&quot;".

Note: This event is a table class member, so you can refer to the fields directly.

Example

Click "Cars" node on the database panel, select [Server Events/Client Scripts], and click [Table Specific] - > [Common] - > [Row_Rendered] server event. The default Row_Rendered event code is shown. Change as follow:

' Note: Row_Rendered is a table class member, so you can refer to the fields (also table class members) directly
Public Sub Row_Rendered()
    ' Change the row color
    If Convert.ToString(Trademark.ViewValue) = "BMW" Then
        RowAttrs("style") = "color: red; background-color: #ccffcc"
    End If

    ' Change the cell color
    If Convert.ToInt32(Cyl.CurrentValue) = 4 Then
        Cyl.CellAttrs("style") = "background-color: #ffcccc"
    ElseIf Convert.ToInt32(Cyl.CurrentValue) = 6 Then
        Cyl.CellAttrs("style") = "background-color: #ffcc99"
    ElseIf Convert.ToInt32(Cyl.CurrentValue) = 8 Then
        Cyl.CellAttrs("style") = "background-color: #ffccff"
    End If

    ' Change text style
    If Convert.ToString(Category.CurrentValue) = "SPORTS" Then
        Category.ViewAttrs("style") = "color: #00cc00; font-weight: bold; background-color: #ffff99"
    End If

End Sub

Row_Selecting

This event will be called before selecting a record.

Row_Selected

This event will be called after selecting a record. The argument is the record selected.

Row_UpdateConflict

This event will be called if conflicts is found before updating a record (if Check Conflicts is enabled, see Table Setup). The arguments of the event are the recordsets of the old and new record updated.

You can use this event to resolve the conflicts according to your own criteria. If you want to ignore conflicts or you have resolved the conflicts in the event (by setting new values to the argument rsnew) and want to continue update, return False. Otherwise, return True. By default the event returns True.

Row_Updating

This event will be called before updating a record. The arguments of the event are the old and new record to be updated as OrderedDictionary objects.

Example

Make sure a field value is not changed

Public Function Row_Updating(rsold As OrderedDictionary, ByRef rsnew As OrderedDictionary) As Boolean
    If rsnew("Date") < rsold("Date") Then
        CancelMessage = "The new date must be later than the old date."
        ' To cancel, set return value to False
        Return False         
    Else        
        Return True
    End If
End Function

Row_Updated

This event will be called after updating a record. The arguments of the event are the old and new record updated as OrderedDictionary objects.

Email_Sending

This event is fired before the email notification is sent. You can customize the email content using this event. Email_Sending event has the following parameters:

Email - the email object instance which contain all the information about the email to be sent. It is an instance of the cEmail class, refer to aspxfn*.vb/cs for members of the object.

Args - an instance of hashtable object which contains additional information. For Add, the new record in the data type of an OrderedDictionary can be access by Args("Rs"). If Edit/Update, the old record in the data type of an OrderedDictionary can be access by Args("RsOld"), the new record in the data type of an OrderedDictionary can be access by Args("RsNew").

Return False in the event if you want to cancel the email sending.

Note: This event is a table class member.

Example

Use a field value of the the new record in the email

Public Function Email_Sending(ByRef Email As cEmail, Args As Hashtable) As Boolean
    If Page.PageID = "add" Then ' if Add page
    
    Dim rs As OrderedDictionary = Args("Rs")
        Email.Content = Email.Content & vbCrLf & "Added by " & rs("UserID")
    End If
    Return True
End Function


Table-Specific -> Add/Copy page

Page_Load

This event will be called after connecting to the database.

Page_Load

This event will be called after connecting to the database.

Page_Redirecting

This event will be called before redirecting to other page. The argument is the URL to be redirected to.

By default after inserting a record user is redirected back to the List page. You can change that by using Return Page (see Table Setup). However, If you want to change by code, you can also use this event.

Form_CustomValidate

This event is fired after the normal form validation. You can use this event to do your own custom validation. In general, the form data can be accessed by <Table>.<Field>.FormValue (e.g. Cars.HP.FormValue). Refer to the generated code for actual variable names.

A parameter CustomError is passed to the event, add your error message and return False if the form values do not pass your validation.

Note: This event is a page class member.

Example

Make sure an integer field value meet a certain requirement

Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
    If CInt(Orders.Qty.FormValue) Mod 10 <> 0 Then
        ' Return error message in CustomError
        CustomError = "Order quantity must be multiples of 10."
        Return False
    Else        
        Return True
    End If    
End Function

Table-Specific -> Delete Page

Page_Load

This event will be called after connecting to the database.

Page_Unload

This event will be called before closing database connection.

Page_Redirecting

This event will be called before redirecting to other page. Event argument is the URL to be redirected to.

By default after deleting record(s) user is redirected back to the List page. You can change that using this event.

Table-Specific -> Edit Page

Page_Load

This event will be called after connecting to the database.

Page_Unload

This event will be called before closing database connection.

Page_Redirecting

This event will be called before redirecting to other page. Event argument is the URL to be redirected to.

By default after updating a record user is redirected back to the List page. You can change that by using Return Page (see Table Setup). However, If you want to change by code, you can use this event.

Table-Specific -> List Page

Page_Load

This event will be called after connecting to the database.

Page_Unload

This event will be called before closing database connection.

Page_Redirecting

This event will be called before redirecting to other page. Event argument is the URL to be redirected to.

Form_CustomValidate

This event is fired after the normal form validation. You can use this event to do your own custom validation. In general, the form data can be accessed by <Table>.<Field>.FormValue (e.g. Cars.HP.FormValue). Refer to the generated code for actual variable names.

A parameter CustomError is passed to the event, add your error message and return False if the form values do not pass your validation.

ListOptions_Load

This event will be called before the main table is rendered. Use this event to modify the non data columns of the main table (i.e. the links and the checkbox for each record). You can modify these columns or add your own columns using this event. You can get a column by name using the ListOptions.GetItem(name) method, the following predefined names are reserved, do not use them for your own columns:

  • copy
  • delete
  • edit
  • detail_<DetailTable>
  • checkbox

Note: This event is a page class member.

Example

Sub ListOptions_Load()
    Dim Col ' New Column
    Set Col = ListOptions.Add("new") ' Add a new column
    Col.OnLeft = True ' Show on left
    Col.Header = "My HTML Caption" ' Caption of the column
    ListOptions.MoveItem "new", 0 ' Move to first column
End Sub

ListOptions_Rendered

This event will be called before a record is rendered. Use this event to modify content of the non data columns for the record.

Note: This event is a page class member.

Example

Set the content of the new column.

Sub ListOptions_Rendered()
    ListOptions.GetItem("new").Body = "My HTML content for the column"
End Sub

Table-Specific -> Multi-Update Page

Page_Load

This event will be called after connecting to the database.

Page_Unload

This event will be called before closing database connection.

Page_Redirecting

This event will be called before redirecting to other page. Event argument is the URL to be redirected to.

By default after updating records user is redirected back to the List page. You can change that by using this event.

Table-Specific -> Report Page

Page_Load

This event will be called after connecting to the database.

Page_Unload

This event will be called before closing database connection.

Page_Redirecting

This event will be called before redirecting to other page. Event argument is the URL to be redirected to.

Table-Specific -> Search Page

Page_Load

This event will be called after connecting to the database.

Page_Unload

This event will be called before closing database connection.

Page_Redirecting

This event will be called before redirecting to other page. Event argument is the URL to be redirected to.

By default user is redirected to the List page after the search criteia is processed. You can change that by using this event.

Table-Specific -> View Page

Page_Load

This event will be called after connecting to the database.

Page_Unload

This event will be called before closing database connection.

Page_Redirecting

This event will be called before redirecting to other page. Event argument is the URL to be redirected to.

Other -> Login Page

Page_Load

This event will be called at the beginning of the page.

Page_Unload

This event will be called at the end of the page.

Page_Redirecting

This event will be called before redirecting to other page. Event argument is the URL to be redirected to.

By default user is redirected to the default page (e.g. default.aspx) after successful login. You can change that by using this event.

User_LoggingIn

This event will be called before validating the username and password. Note: This event is a page class member.

User_LoggedIn

This event will be called after the user login. Note: This event is a page class member.

Form_CustomValidate

This event is fired after the normal form validation. You can use this event to do your own custom validation. In general, the form data can be accessed by <Table>.<Field>.FormValue (e.g. Cars.HP.FormValue). Refer to the generated code for actual variable names.

A parameter CustomError is passed to the event, add your error message and return False if the form values do not pass your validation.

Note: This event is a page class member.

User_LoginError

This event will be called if the user fail to login.
Other -> Logout Page

Page_Load

This event will be called at the beginning of the page.

Page_Unload

This event will be called at the end of the page.

Page_Redirecting

This event will be called before redirecting to other page. Event argument is the URL to be redirected to.

By default user is redirected to the default page (e.g. default.aspx) after successful login. You can change that by using this event.

User_LoggingOut

This event will be called before user logout. Note: This event is a page class member.

User_LoggedOut

This event will be called after user logout. Note: This event is a page class member.

Other -> Registration Page

Page_Load

This event will be called at the beginning of the page.

Page_Unload

This event will be called at the end of the page.

Page_Redirecting

This event will be called before redirecting to other page. Event argument is the URL to be redirected to.

By default user is redirected to the default page (e.g. default.aspx) after successful login. You can change that by using this event.

Email_Sending

This event is fired before the email notification is sent. You can customize the email content using this event. Email_Sending event has the following parameters:

Email - the email object instance which contain all the information about the email to be sent. It is an instance of the cEmail class, refer to aspxfn*.vb/cs for members of the object.

Args - an dictionary object which contains additional information. For registration page, the new record in the data type of a recordset can be accessed by Args("Rs").

Return False in the event if you want to cancel the email sending.

Note: This event is a page class member.

Form_CustomValidate

This event is fired after the normal form validation. You can use this event to do your own custom validation. In general, the form data can be accessed by <Table>.<Field>.FormValue (e.g. Cars.HP.FormValue). Refer to the generated code for actual variable names.

A parameter CustomError is passed to the event, add your error message and return False if the form values do not pass your validation.

User_Registered

This event is fired after successful regsitration of a new user. Argument is a recordset of the new record in the user table.

User_Activated

This event is fired after activating a new user (if user activation is required, see Security Settings). Argument is a recordset of the new record in the user table.

Other -> Change Password Page

Page_Load

This event will be called at the beginning of the page.

Page_Unload

This event will be called at the end of the page.

Page_Redirecting

This event will be called before redirecting to other page. Event argument is the URL to be redirected to.

By default user is redirected to the default page (e.g. default.aspx) after successful login. You can change that by using this event.

Email_Sending

This event is fired before the email notification is sent. You can customize the email content using this event. Email_Sending event has the following parameters:

Email - the email object instance which contain all the information about the email to be sent. It is an instance of the cEmail class, refer to aspxfn*.vb/cs for members of the object.

Args - an instance of dictionary object which contains additional information. For Change Password page, the old data of the records in the data type of OrderedDictionary can be accessed by Args("RsOld"), the new data of the records in the data type of recordset can be accessed by Args("RsNew").

Return False in the event if you want to cancel the email sending.

Note: This event is a page class member.

Form_CustomValidate

This event is fired after the normal form validation. You can use this event to do your own custom validation. In general, the form data can be accessed by <Table>.<Field>.FormValue (e.g. Cars.HP.FormValue). Refer to the generated code for actual variable names.

A parameter CustomError is passed to the event, add your error message and return False if the form values do not pass your validation.

Note: This event is a page class member.

Other -> Password Recovery Page

Page_Load

This event will be called at the beginning of the page.

Page_Unload

This event will be called at the end of the page.

Page_Redirecting

This event will be called before redirecting to other page. Event argument is the URL to be redirected to.

By default user is redirected to the login page after successful login. You can change that by using this event.

Email_Sending

This event is fired before the email notification is sent. You can customize the email content using this event. Email_Sending event has the following parameters:

Email - the email object instance which contain all the information about the email to be sent. It is an instance of the cEmail class, refer to aspxfn*.vb/cs for members of the object.

Args - an instance of dictionary object which contains additional information. For Password Recovery Page, the old data of the records in the data type of OrderedDictionary can be accessed by Args("Rs").

Return False in the event if you want to cancel the email sending.

Note: This event is a page class member.

Form_CustomValidate

This event is fired after the normal form validation. You can use this event to do your own custom validation. In general, the form data can be accessed by <Table>.<Field>.FormValue (e.g. Cars.HP.FormValue). Refer to the generated code for actual variable names.

A parameter CustomError is passed to the event, add your error message and return False if the form values do not pass your validation.

Note: This event is a page class member.

User_RecoverPassword

This event is fired after the password is recovered. Argument is a recordset of the user's record in the user table.

 

Client Scripts

In general, each page has two blocks of JavaScripts:

Client Script - the first block of JavaScript to be included at the beginning of the page, you can put your JavaScript variables and functions there. The View Tag (for display) and Edit Tag (for input) of the fields supports Custom Attributes (See Field Setup) so you can add your own attributes to work with your own JavaScript included here.

Startup Script - the second block of JavaScript to be included at the end of the page, you can put code here to "start up" your JavaScript.

Global -> Pages with header/footer

Client Script

The script will be placed in the header and therefore included in all pages with header.

Startup Script

The script will be placed in the footer and therefore included in all pages with footer.

Global Code

JavaScript code to be included in all pages with header. This may contain your global constants, variables and functions.
Table-Specific -> Add/Copy page

Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.

Form_CustomValidate

This function is called after the normal form validation. You can use this event to do your own custom validation. The form object can be accessed by the parameter fobj. In general, the field can be referred to as fobj.elements["x_FieldName"]. (The element names have different names in Inline/Grid Add/Edit of List page, always refer to the generated code for the actual form element names.) Return False if the form values do not pass your validation.

Note: This function is a member of the JavaScript page class.

Example

Make sure an integer field value meet a certain requirement

function(fobj) { // DO NOT CHANGE THIS LINE!
    var qty = parseInt(fobj.elements["x_Qty"]);
    if (qty % 10 != 0) {         
        
alert("Order quantity must be multiples of 10.");
        return false; // return false if invalid
    }
    return true;
}

Table-Specific -> Delete Page

Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.
Table-Specific -> Edit Page

Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.

Form_CustomValidate

This function is called after the normal form validation. You can use this event to do your own custom validation. The form object can be accessed by the parameter fobj. Return False if the form values do not pass your validation.

Table-Specific -> List Page

Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.

Form_CustomValidate

This function is called after the normal form validation. You can use this event to do your own custom validation. The form object can be accessed by the parameter fobj. Return False if the form values do not pass your validation.

Table-Specific -> Multi-Update Page

Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.

Form_CustomValidate

This function is called after the normal form validation. You can use this event to do your own custom validation. The form object can be accessed by the parameter fobj. Return False if the form values do not pass your validation.

Table-Specific -> Report Page

Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.
Table-Specific -> Search Page

Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.

Form_CustomValidate

This function is called after the normal form validation. You can use this event to do your own custom validation. The form object can be accessed by the parameter fobj. Return False if the form values do not pass your validation.

Table-Specific -> View Page

Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.
Other -> Login Page

Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.

Form_CustomValidate

This function is called after the normal form validation. You can use this event to do your own custom validation. The form object can be accessed by the parameter fobj. Return False if the form values do not pass your validation.

Other -> Registration Page

Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.

Form_CustomValidate

This function is called after the normal form validation. You can use this event to do your own custom validation. The form object can be accessed by the parameter fobj. Return False if the form values do not pass your validation.

Other -> Change Password Page

Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.

Form_CustomValidate

This function is called after the normal form validation. You can use this event to do your own custom validation. The form object can be accessed by the parameter fobj. Return False if the form values do not pass your validation.

Other -> Password Recovery Page

Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.

Form_CustomValidate

This function is called after the normal form validation. You can use this event to do your own custom validation. The form object can be accessed by the parameter fobj. Return False if the form values do not pass your validation.

Note: It is recommended that you develop your server event and client scripts in the generated script so you can edit and test it immediately. When you finish your custom script, copy it to ASP.NET Maker custom script editor and save it.

 

Objects in ASP.NET Maker Generated Code

The following objects are available in the generated code and you can use them in the Server Events to add more power to the code. The most important objects are:

Page Object
The Page object is generated for most pages. You can access the object properties using the dot notation (e.g. Page.PageID). The page class is inherited from the class AspNetMakerPage. The methods and properties of the page class varies with page, for the complete list of methods and properties, please refer to the class AspNetMakerPage and the generated class "c<Table>_<PageID>" (e.g. cCars_list) in the generated scripts.

Note: This is NOT the Page property (of type System.Web.UI.Page) of the ASP.NET page.

Table Object
A c<Table> Class is generated for each table and the <Table> object is instantiated for all table level pages. For example, the "cCars" class is generated for the "Cars" table and is instantiated as the "Cars" object. You can access the object properties using the dot notation (e.g. Cars.CurrentAction). For the complete list of methods and properties, please refer to the class "c<Table>" in the generated file "<Table>info.vb/cs".

Field Object
A <Field> object is generated for each field in a table. For example, the "Trademark" object is generated for the "Trademark" field in the "Cars" table. You can access the object properties using the dot notation (e.g. Cars.Trademark.CurrentValue). For the complete list of methods and properties, please refer to the class "cField" in the generated file "aspxfn*.vb/cs".

Conn Object
The Conn object stores the connection object and provide methods to work with the database. Please refer to the class "cConnection" in the generated file "aspxfn*.vb/cs" for the complete list of methods and properties.

Security Object
The Security object is used to store the current Advanced Security settings. Please refer to the class "cAdvancedSecurity" in the generated file "aspxfn*.vb/cs" for the complete list of methods and properties.

Email Object
The Email object contains the required information of the email to be sent, the instance of the object will be passed to the Email_Sending events as argument and let you modify the email. Please refer to the class "cEmail" in the generated file "aspxfn*.vb/cs" for the complete list of methods and properties.

MenuItem Object
The MenuItem object contains all information of the menu item, the instance of the menu item will be passed to the MenuItem_Adding events as argument and let you work with the menu item. Please refer to the class "cMenuItem" in the generated file "aspxfn*.vb/cs" for the complete list of methods and properties.

ListOpions Object
The ListOptions object contains all information of the non data columns in the main table of the List page. Please refer to the class "cListOptions" in the generated file "aspxfn*.vb/cs" for the complete list of methods and properties.

Langauge Object
The langauge Object lets you retrieve a phrase of the active langauge during runtime. The phrase can be retrieved in the generated scripts using methods such as Phrase, TablePhrase and FieldPhrase. Please refer to the class "cLanguage" in the generated file "aspsfn*.vb/cs" for the complete list of methods and properties.

There are a few other objects in the generated code, please refer to the generated file "aspxfn*.vb/cs".

 

 

 

 

 

 

 

 

 

 
 ©2004-2010 e.World Technology Ltd. All rights reserved.