Skip to main content

Calling a Server Side Method

Within the #server( ... )# parentheses we supply the syntax to invoke AddShow. Since AddShow is part of ShowTimes, by virtue of Utils being a super class of ShowTimes, we can invoke the method using the ..MethodName syntax. We can also include any input parameters the method needs. In this case, there is one parameter, the ID of the show, which comes from the query.

If we were to look at the generated page, it might contain

#server(..AddShow(43))#

for the first Tickets button

#server(..AddShow(16))#

for the second Tickets button, and so on.

—ShowTimes.csp—
ShowTimes.csp
<html> <body>
<csp:class encoded=1 super="%CSP.Page,Cinema.Utils">
<csp:query 
        name="Times" 
        classname="Cinema.Show" 
        queryname="ShowTimes"
        P1='#(%request.Data("FilmID",1))#'>

<csp:object 
        name="Film" 
        classname="Cinema.Film" 
        objid='#(%request.Data("FilmID",1))#'>

<font> <b>Today's Show Times for #(Film.Title)#</b></font>

<table cellpadding=5> <tr> ... </tr>
<csp:while condition="Times.Next()">
    <tr>
    <td>#(Times.Get("StartTime"))#</td>
    <td>#(Times.Get("TheaterName"))#</td>
    <td align="center">
    <a href=. onClick="#server(..AddShow(#(Times.GetData(1))#))#;return false;">

    <img src="Tickets.gif" width="130" height="39" border="0" 
    alt="Click to order tickets for this show">
    </a>

    </tr>
</csp:while>
</table>
</body> </html>
FeedbackOpens in a new tab