[thelist] RE: asp.net: Why won't InitialValue work

Casey Crookston casey at thecrookstons.com
Wed Dec 22 15:13:27 CST 2004


> I think that you need to set the text property in the textbox to the
> initial value also. Such as
>
> <asp:textbox id="joined" runat="server" text="enter a value" />
>
> <asp:RequiredFieldValidator initialValue="enter a value" id="rfvJoined"
> ControlToValidate="joined"
> ErrorMessage="Required: Enter Date: MM-DD-YYYY" Display="Dynamic"
> runat="server" />


Thanks.  tried that.  If  the user deletes the initial value in the textbox
and submits an empty value it still posts back as if it had a value.  In
other words, the required validator does not trigger.


>
> I didn't have time to test this but I do think it is correct.
>
> ------------------------------------------------------------------------
> ----
> If I include InitialValue="MM-DD-YYYY" in the
> RegularExpressionValidator,
> nothing happens... it's like it's not even there.  If I include it in
> the
> RequiredFieldValidator, it also does not display the initial value, AND
> the
> validator stops working and allows an empty value.  What's with that?
> How
> can I make this work?
>
> <form runat="server">
>
> <asp:textbox id="joined" runat="server" />
>
> <asp:RegularExpressionValidator id="revJoined"
> ControlToValidate="joined"
> ErrorMessage="Formt: Enter Date: MM-DD-YYYY"  Display="Dynamic"
> ValidationExpression="\d{2}-\d{2}-\d{4}" runat="server" />
>
> <asp:RequiredFieldValidator id="rfvJoined" ControlToValidate="joined"
> ErrorMessage="Required: Enter Date: MM-DD-YYYY" Display="Dynamic"
> runat="server" />
>
> </form>






More information about the thelist mailing list