Monday, October 8, 2012

Clear a field on a form

Problem: You want to clear a text box on a form.

You can set the value of the field that is bound to a text box control to be equal to an empty string to clear it.

In order to clear a text box called "Field 1" do the following:

- Add a text box field called "Field 1" and a button to the form. Set the ID of the button to "ClearTextButton"

- On the ClearTextButton_Clicked event handler add the following code

Dim dsMain As XPathNavigator = MainDataSource.CreateNavigator
Dim Field1 As XPathNavigator = dsMain.SelectSingleNode("/my:myFields/my:field1", NamespaceManager)

Field1.SetValue(String.Empty)

No comments:

Post a Comment

About Me

My photo
Toronto, Ontario, Canada
MBA, M.Sc. & MCP