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

This function renders an error message based on a control id and validation error collection. If a validation error is found for the control the error is rendered.

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

HtmlCloseElement(lcElement)

HtmlDataGrid

Creates an HTML table from a cursor and returns the HTML as a string.

HtmlDataGrid(lcAlias,loGridConfig,lcId)

HtmlDateTextBox

Creates a date entry control that allows automatic date capture and conversion.

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

HtmlDropDown

Creates an HTML Drop Down list. The DropDown can be populated from a data source of a cursor, array or collection and by binding an evaluated expression for text and value displays of each list item and you can add an initial first item.

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

HtmlElement

Creates an HTML Element by its element name.

HtmlElement(lcElement,lcContent,lcAttributes,lcId)

HtmlErrorDisplay

Creates an HTML error display 'bar' using the stock bootstrap Alert box that can be easily embedded into a page.

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

HtmlFormClose

Creates an HTML form close element.

HtmlFormClose()

HtmlFormOpen

Creates an HTML form open element tag.

HtmlFormOpen(lcAction,lcMethod,lcAttributes,lcId)

HtmlImage

Creates an HTML Image tag.

HtmlImage(lcSrc,lcAttributes,lcId)

HtmlLabel

Creates a

HtmlLink

Creates an HTML link (a href) element.

HtmlLink(lcLink, lcText,lcAttributes, lcId)

HtmlListBox

Creates an HTML Listbox. The listbox can be populated from a data source of a cursor, array or collection and by binding an evaluated expression for text and value displays of each list item.

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

Creates an HTML Radio Button control.

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

HtmlRecord

Displays a single record or object as an HTML form from a cursor or object as a string:

HtmlRecord(lvData, loConfig)

HtmlRssFeed

Method that generates an RssFeed as an HTML based element list.

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-2024 • Updated: 06/14/17
Comment or report problem with topic