Contents

 
Home
ASPRunner Professional 7.0 manual
Prev Page Next Page
 
 

Insert button

 

To add the button to a web page, follow the instructions below.

1. Proceed to the Visual Editor and select a page you wish to modify.
2. Right click somewhere on the page, select Insert -> Button.
3. Type in the button caption and code to be executed after button is pressed. You can add both client-side (Javascript) and server-side (ASP) events. Click OK.

insert_button_code

4. Now button is added to your web page. You can drag the button to change its location.

insert_button_res

To edit the code, right click the button and select Properties. Also you can edit the code on the Events page.

Example 1. Insert "Add this product to shopping cart" button

For the Edit/View pages the keys parameter in the OnServer event contains the information about the current record. To access specific key column you can use keys("KeyFieldName").

For example, there is a Products table. To insert Add this product to shopping cart button on the View page, add the following code to the OnServer event (Server tab):

if not isnull(keys("ProductID")) then

//add new records to the ShoppingCart table

//save current username in the UserID field

set ShoppingCart = dal.Table("ShoppingCart")

ShoppingCart.Product = keys("ProductID")

ShoppingCart.Quantity = 1

ShoppingCart.UserID = Session("UserID")

ShoppingCart.Add()

end if

result("txt") = "Product was added"

and this code to the OnAfter event (Client After tab):

var message = result["txt"] + ".";

For more information about using Data Access Layer (DAL), see Data Access Layer.

Example 2. Send records selected on the List page via email

For the List page the keys parameter in the OnServer event contains the information about all records that are selected on this page:

keys(0)("ID1"), keys(0)("ID2") - first selected record

keys(1)("ID1"), keys(1)("ID2") - second selected record

...

To send records selected on the List page via email, add the following code to the OnServer event (Server tab):

Dim email_msg

email_msg = ""

email_msg = email_msg & "List of records" & vbcrlf

For n = 0 To keys.Count-1

r_number = n+1

email_msg = email_msg & "Record: " & r_number & vbcrlf

//select values from TableName based on keys(n)("ID1")

Set TableName = dal.Table("TableName")

Set rstmp = TableName.Query("ID1=" & keys(n)("ID1"),"")

email_msg = email_msg & "FieldName1: " & rstmp("FieldName1") & vbcrlf

email_msg = email_msg & "FieldName2: " & rstmp("FieldName2") & vbcrlf

email_msg = email_msg & vbcrlf

rstmp.close

set rstmp=nothing

Next

set params = CreateObject("Scripting.Dictionary")

params("to")="test@test.com"

params("subject")="Sample subject"

params("body")=email_msg

runner_mail(params)

For more information about using Data Access Layer (DAL), see Data Access Layer.

Example 3. Modify the value of a field for all selected records on the List page

To modify the value of a field for all selected records on the List page, add the following code to the OnServer event (Server tab):

for each val in keys

strUpdate = "update Invoices set Status='Paid' where InvoiceID=" &val("InvoiceID")

CustomQuery(strUpdate)

next

Example 4. Make a button redirect to another page

To make a button redirect to another page, add the following code to the OnBefore event (Client Before tab) or OnAfter event (Client After tab):

location.href="http://cnn.com";

Converted from CHM to HTML with chm2web Standard 2.85 (unicode)