VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering

You are here: Visual Basic > Advanced VB6 tutorial > Chapter 17

Navigating Between DHTML Pages and Persisting State

If you wish to programmatically navigate between DHTML pages in your application, you need to manipulate the BaseWindow object. This is only logical because, as you will recall, BaseWindow represents the browser—and the browser does the navigating between pages.

Assume, for instance, that you supply the user with a button to click. The button takes the user to another DHTML page furnished by your application. In the button’s onclick event procedure, you might write the line:

BaseWindow.Navigate "CustSurvey_CSMain.html"

This causes the browser to navigate to the indicated page. Note the name of the page in the string: It is formed from the project name and an underscore and the name of the page with an html extension. (This is the name of the temporary file created for the page on the user’s browser.)

You may also want to persist data between calls to the same page, or to pass information between pages. Once again, you will call on the browser to help you with its Property Bag. You use the PutProperty method to write information to the Property Bag.

Suppose, for example, that you wanted to save information about the state of a particular element on the DHTML page, just before navigating to another page. You would make up an appropriate property name, and then you would store a string value to that property. The code for doing so might look like this:

If optChoiceGreen.Checked Then
PutProperty BaseWindow.Document, "optColor", "Green"
End If

In the example, the programmer has invented a property named optColor and stored the value "Green" to this property. Note that the call to PutProperty required three arguments:

  • Object for which you are storing the property

  • Name of the property

  • Value of the property

Later in vthe same session, the page may be reloaded. If you want to retrieve the information that was stored for the optColor property, you could put a call to GetProperty in the Load event of the DTHTMLPage object:

stroptColor = GetProperty(BaseWindow.Document, "optColor")

By using PutProperty and GetProperty in tandem, you can cause information about a page to become persistent across multiple sessions.


<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved