Visual InterDev

setBookmark Method

See Also      Applies To

Sets the bookmark for pointing to a particular record.

Syntax

object.setBookmark(strBookmark)

Parameters

object

A script object.

strBookmark

A string name of a bookmark.

Remarks

To get the bookmark, use the getBookmark method.

The getBookmark and setBookmark methods are similar to ADO recordset bookmarks, but can be persisted between pages.

Because the default behavior when binding to data in ASP requires your code to Close and Reopen the recordsets each time the page is served, and because ADO bookmarks are invalid once the recordset is closed, Microsoft® Visual InterdDev™ implements a custom bookmark, that behaves just like an ADO bookmark.

Thus, you can store a bookmark, close the recordset, re-open the recordset and set the bookmark and you will be at the correct record.

Example

The following script stores a bookmark, closes the recordset, re-opens the recordset, and sets the bookmark so that you will be at the correct record.

Sub SampleBookmark()
dim tmpBookMark
   myRS.Open()
   myRS.moveNext() ' now we are on the second record
   tmpBookMark = myRS.getBookMark()
   'now close the recordset
   myRS.Close()
   'typically your bookmark is invalid, but in Visual InterDev it is not
   'we will re-open this recordset, but assume this is another page perhaps
   myRS.Open()
   'let's also assume that several records have been inserted before 
   'and after the record we bookmarked
   myRS.setBookMark(tmpBookMark)
   'we are now on the same record we were before (which this time is not necessarily the 2nd record)
   
End Sub