Mwt entw a value Miaft enter a

Must ruler a vi'j?

¿j; Locd rtrarrt

Figure 5-9 : The result when the first validator on a given field is set to Static display The ErrorMessage associated with the first validator (which hasn't been fired) is "Out of Range". Looking at Figure 5-9, you can see that the space between the text box and the beginning of the first "Must enter a value" string is about what might be required to fit "Out of Range". Because we have the actual source that generated this page, we can see what the browser uses to render the page. The following HTML code is the table row returned to the browser in which the range validator is located. (The code has been reformatted for readability.)

<input name="Range" id="Range" type="text" size="10" /> </td> <td>

<span id="ValRange" controltovalidate="Range" errormessage="Out of Range" type="Integer"

evaluationfunction="RangeValidatorEvaluateIsValid" maximumvalue="12" minimumvalue="1" style="color:Red;visibility:hidden;"> Out of Range

controltovalidate="Range" errormessage="Must enter a value." display="Dynamic"

evaluationfunction="RequiredFieldValidatorEvaluateIsValid" initialvalue=""

style="color:Red;display:none;"> Must enter a value. </span> </td> </tr>

From this HTML output, you can verify that the space for the "Out of Range" text is present in the rendered HTML. Thus, in general, when two validators are present, you'll want to set Display to Dynamic.

0 0

Post a comment