Required field validator static text does not display

M

Milan

Hi,
I am having a problem with displaying a * to a required field.

There seems to be a problem with this and the static value does not
appear unless you submit the page.
I am trying to display the static text as soon as the page is loaded
in the browser.

Does anyone know if there is a bug with the aps.net validator
controls? Or is this not possible.
I also have a summary validator control.

A sample :-

<asp:textbox id="txtSurname" Runat="server"
MaxLength="50"></asp:textbox>
<asp:requiredfieldvalidator display="static" id="valSurname"
Runat="server" Visible="True" ControlToValidate="txtSurname"
ErrorMessage="Surname must be entered.">*</asp:requiredfieldvalidator>

Thanks Milan
 
H

Hans Kesting

Milan said:
Hi,
I am having a problem with displaying a * to a required field.

There seems to be a problem with this and the static value does not
appear unless you submit the page.
I am trying to display the static text as soon as the page is loaded
in the browser.

Does anyone know if there is a bug with the aps.net validator
controls? Or is this not possible.
I also have a summary validator control.

Sorry, the validator doesn't work this way.
Both "Text" and "ErrorMessage" are only shown after an error-check
(on submit for instance). If you have a validation summary, then the
"ErrorMessage" is shown in that summary, the "Text" is always shown
on the position of the validator.

Hans Kesting
 
S

Shiva

Hi,
The purpose of Display property is something else. If you set it to static,
it indicates that space should be reserved for error messages in the page
flow layout on the browser window; it does not mean validator control error
msgs should be displayed on page load itself.

One option to show the '*' on initial page display itself is to call the
page's Validate() method in the page load event.

Hoep this helps.

Hi,
I am having a problem with displaying a * to a required field.

There seems to be a problem with this and the static value does not
appear unless you submit the page.
I am trying to display the static text as soon as the page is loaded
in the browser.

Does anyone know if there is a bug with the aps.net validator
controls? Or is this not possible.
I also have a summary validator control.

A sample :-

<asp:textbox id="txtSurname" Runat="server"
MaxLength="50"></asp:textbox>
<asp:requiredfieldvalidator display="static" id="valSurname"
Runat="server" Visible="True" ControlToValidate="txtSurname"
ErrorMessage="Surname must be entered.">*</asp:requiredfieldvalidator>

Thanks Milan
 
D

David Jessee

Okay. you're looking at 2 different things. The First is the Asterisk that
should always be displayed, which is really just a visual decoration for the
textbox, and then there's the validation control, which is a behavior.

Take the Asterisk out of the validation control totally. The next to the
text box, type an asterisk and format it whatever way you want.
 
G

Guest

Hi,
Thanks for clarifying how the validators work. I tried the page.validate on
page load and it partially does the trick, but other error messages show up
in the summary.

I will use the obvious method of displaying the asterisks as mentioned by
David.
Milan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top