Library wwHtmlHelpers

The wwHtmlHelpers library contains a set of HTML helper functions that allow easy creation of HTML elements and form controls with a single line of code.

Helpers are useful for use in raw FoxPro code in Process class methods where you can create HTML and output it like this:

*** Create a textbox
Response.Write( HtmlTextBox("txtLastName",loCustomer.oData.LastName) )

You can also easily use Html Helpers in Templates or Scripts:

< %= HtmlTextBox("txtLastName",loCustomer.oData.LastName) % >

which makes these helper functions nice and quick ways to embed more complex HTML into the page.

Helpers are also great to use in Web Control Framework (or the HtmlDataGrid) binding expressions. For example imagine you want to embed a hyperlink into a column of a wwWebDataGrid - you can do this by binding HtmlLink() to a column expression like this:

loColumn.Expression = [HtmlLink("customer.wwd?id=" + TRANS(cust.pk),cust.company)]

Automatic PostBack on Input Controls

The various input controls like HtmlTextBox, HtmlCheckBox, HtmlListBox/HtmlDropDown etc. all automatically pick up their values from the Web Connection Request.Form() object on a POST operation by default. This means that you don't have to explicitly assign a value to the control on a POSTBACK operation - the control will automatically display the last assigned or altered value from the user from the Request.Form() buffer.

If you bind like this:

lcHtml = HtmlTextBox("txtCompany",loCustomer.oData.Company)]

The value first checks for Request.Form("txtCompany") and if found assigns that value rather than the value of loCustomer.oData.Company. In most cases this is the desired behavior since first display will render the value from the object, and subsequent displays of the page will render the value from the Request.Form() buffer.

To override AUTOPOSTBACK behavior you can append ":FORCED" to the end of the value. The function will strip the ":FORCED" postfix of the resulting string to set the value of the control:

lcHtml = HtmlTextBox("txtCompany",loCustomer.oData.Company + ":FORCED")]

This causes the loCustomer.oData.Company value to always be assigned every time the expression is run - no retrieval of Request.Form("txtCompany") occurs. The ":FORCED" is simply removed from the result string (ie. "West Wind Technologies:FORCED" is turned into "West Wind Technologies" only).

Remarks

All the functions described in this library are not class methods, but plain functions. They are accessed simply by their names without any class prefix:

< %= HtmlDataGrid("tt_cust") % >

Class Members

MemberDescription

HtmlBindingError

o.HtmlBindingError(lcControlId,loErrors,lcMessage,lcAttributes)

HtmlButton

Creates a non-submit HTML button. Use this button for JavaScript link handling.

HtmlButton(lcName,lcText,lcAttributes)

HtmlCheckBox

Creates an HTML CheckBox as an input element.

HtmlCheckBox(lcName,lcText,llValue,lcAttributes)

HtmlCloseElement

Creates an HTML close element tag

Example:

? HtmlCloseElement("div")  && </div>

HtmlCloseElement(lcElement)

HtmlDataGrid

HtmlDataGrid(lcAlias,loGridConfig,lcId)

HtmlDateTextBox

o.HtmlDateTextBox(lcName,ltValue,lcAttributes,lnNativeMode,lcContainerAttributes)

HtmlDropDown

HtmlDropDownBox(lcName,lcSelectedValue, lcDataSource, lcDataValueField, lcDataTextField, lcAttributes, lcInitialText, lcInitialValue)

HtmlElement

Creates an HTML Element by its element name.

HtmlElement(lcElement,lcContent,lcAttributes,lcId)

HtmlErrorDisplay

o.HtmlErrorDisplay(lcMessage, lcImage, lcAttributes,
lcHeader, llDismissable)

HtmlFormClose

Creates an HTML form close element.

This is a very simple function that simply returns a tag. It's provided mainly for consistency.

Example:

? HtmlFormClose()  && </form>

HtmlFormClose()

HtmlFormOpen

HtmlFormOpen(lcAction,lcMethod,lcAttributes,lcId)

HtmlImage

HtmlImage(lcSrc,lcAttributes,lcId)

HtmlLabel

o.wwHtmlHelpers.HtmlLabel(lcText,lcFor,lcAttributes,lcId)

HtmlLink

HtmlLink(lcLink, lcText,lcAttributes, lcId)

HtmlListBox

HtmlListBox(lcName,lcSelectedValue,lcDataSource, lcDataValueField, lcDataTextField, lcAttributes, lcInitialText, lcInitialValue)

HtmlOpenElement

Creates an opening HTML element tag.

HtmlOpenElement(lcElement,lcAttributes,lcId)

HtmlPager

Creates an HTML pager display that shows a selected page and buttons for selecting other pages.

o.HtmlPager(lcId,lnPage,lnTotalPages,lnMaxButtons, lcBaseUrl, lcPageQueryString)

HtmlPassword

Works like HtmlTextBox but displays password characters instead of text.

HtmlPassword(lcName,lcValue,lcAttributes)

HtmlRadioButton

HtmlRadioButton(lcName,lcText, llChecked, lcValue,lcAttribute)

HtmlRecord

HtmlRecord(lvData, loConfig)

HtmlRssFeed

o.HtmlRssFeed(loConfig)

o.wwHtmlHelpers.

HtmlSubmitButton

Creates an HTML submit button. This button submits a form to the server via POST operation.

HtmlSubmitButton(lcName,lcText,lcAttributes)

HtmlTextArea

Creates a multiline HTML Text Area as an input element.

HtmlTextArea(lcName,lcValue,lcAttributes)

HtmlTextBox

Creates an HTML Textbox as an input element.

HtmlTextBox(lcName,lcValue,lcAttributes)

See also:

Class wwHtmlHelpers

© West Wind Technologies, 1996-2022 • Updated: 06/14/17
Comment or report problem with topic