Adding an initialization string

You can also include an initialization string specifying the type of viewer to be used. This optional parameter may be written as init='ViewerType' where ViewerType may be any one of the following:

Be careful when using this parameter, however, since you need to know what type of browser the user is using.

Note:    If you wish to reconnect to the Page Server within the same browser session, you can append the CONNECT parameter to the initialization string. This allows the user to re-enter parameter values and logon information, as well as rerun the report if necessary.

The following function checks to see which browser the client is using: Netscape Navigator or Internet Explorer. It then selects either the Navigator plugin or the ActiveX viewer.

GetViewer function

function GetViewer()

{

    var BrowseInfo;

    //Prompt for browser information.

    BrowseInfo = String(Request.ServerVariables.Item("HTTP_USER_AGENT"));

    //If the browser is Internet Explorer, then use ActiveX.

    if (BrowseInfo.search(/MSIE/i) != -1)

        return ("actx");

    //This is not Internet Explorer, use the Navigator plugin.

    else if (BrowseInfo.search(/MSIE/i) == -1)

        return( "nav_plugin");

}

The line to load the viewer may then be modified as follows:

"<a target='_blank' href='viewrpt.cwr?id=" + "CurrentReportID + " & apstoken=" +

    Server.URLEncode(LogonToken) + "&init=" + GetViewer() + "'> View Report</A>"

End of lesson

While this lesson may not cover everything there is to know about Report Viewers, it should give you a general understanding of how to load a Report Viewer and display a report.

For more information on Crystal Report Viewers, see Crystal Web Request (CWR).

For information on viewing reports that contain parameters, see Viewing a report containing specific parameter values.

Go to next lesson:

Lesson 3c: Renaming reports



Crystal Decisions, Inc.
http://www.crystaldecisions.com
Support services:
http://support.crystaldecisions.com