Validating the HtmlPlaceholderControl
The first control that we will build is a custom validation control that works with the HtmlPlaceholderControl
. Our validator will ensure that some text has been entered into the control before the page can be saved. If the author forgets to fill in content, the page will not save and an error message appears on the screen.
The figure below shows how the control works when completed. The author has left HtmlPlaceholderControl1
empty. When he or she tries to save the page, an error message, This is a required field, appears next to the placeholder, instructing him or her to fill it out before proceeding.
Retrieving the Current Value of the HtmlPlaceholderControl
In order to validate the HtmlPlaceholderControl
, we need to first read off its contents. There are two ways to get its stored value—we could use server-side or client-side scripts.
We could choose to use server-side scripts and get the value stored in the Html
property of the HtmlPlaceholderControl...