Printing the child folders for the current folder

In the next part of the code, the InfoStore object is retrieved using the RetrieveIstore function.


//Try to retrieve the InfoStore object.

if (IStore==null)

    //If it failed redirect the user to the logon page.

    

    RedirectWithFrames("LogonForm.csp");


//Otherwise display the folders and the "Up a Level" link.

else {


  Response.Write ("<B>Folders</B><BR><BR>");



If the RetrieveIStore function fails, then there is a rather large problem: there is no way to authenticate the current user. Thus, the only option available is to redirect the user back to the logon page. Since this tutorial uses frames, client side JavaScript is used to redirect the user and overlay the frames. See Folders.csp for details. If the RetrieveIstore function succeeds, then the folders are displayed for the authenticated user.

Example

//Retrieve the parent's ID for the current folder.

    ParentID = RetrieveParentID(IStore,CurrentFolderID);

    //Check to see if the query was successful.

    if (ParentID != null) {


        //If this is not the top level of folders display the "Up a Level" link.

        if (CurrentFolderID != 0)

            Response.Write ("<A HRef='Home.csp?FolderID="+ParentID + "' Target='_top'>Up a Level</A><BR><BR>");

            

    }        

    else

        Response.Write ("There was an error trying to retrieve the parent folder.");

  

  //Print the child folders.

  Result = PrintChildFolders(IStore,CurrentFolderID)

  if (!Result)

    Response.Write ("There was an error trying to retrieve the sub-folders.");

}

Remarks

Note the manner in which the "Up a Level" link is built:

Response.Write ("<A HRef='Home.csp?FolderID="+ParentID + "' Target='_top'>Up a Level</A><BR><BR>");

As was the case when building the links to each sub-folder (see, Processing the results of the query), the parent folder ID is used together with Home.csp to produce the "Up a Level" link.

End of lesson

You now have a working copy of Folders.csp. To see a full version of the CSP page that you've created, see Folders.csp

Go to next lesson:

Lesson 2b: Listing the reports in a folder



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