Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 21st, 2004, 10:03 AM
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to lucho1970
Default Enabling Required Field Validator prob.

I have a check box on a form that, when checked, enables a bunch of fields on the form. These fields have Required Field Validators attached to them.

I have no problem enabling them and disabling them based on the check box, the problem I am having is that as soon as they are enabled, they are all validated and their messages displayed.

In other words, I don't want to see a message or any indication that they are invalid simply by enabling them. I want this to happen once they try to submit the form, or when they leave the text box without populating it.

Any Suggestions?

Luis

 
Old October 21st, 2004, 12:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Are you enabling a linkbutton control at all, or another form of a button?
 
Old October 23rd, 2004, 10:14 AM
Authorized User
 
Join Date: Oct 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi luis, i tried to reproduce your problem, but it is working well for me. please, can you copy this code and try yourself?


<%@ Page Language="VB" %>
<script runat="server">

    ' Insert page code here
    '

    Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs)
        TextBox1.enabled = not TextBox1.enabled
        TextBox2.enabled = not TextBox2.enabled
    End Sub

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            <asp:CheckBox id="CheckBox1" runat="server" OnCheckedChanged="CheckBox1_CheckedChanged" AutoPostBack="True"></asp:CheckBox>
        </p>
        <p>
            <asp:TextBox id="TextBox1" runat="server" Enabled="False"></asp:TextBox>
            <asp:TextBox id="TextBox2" runat="server" Enabled="False"></asp:TextBox>
        </p>
        <p>
            <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox1" EnableClientScript="Try"></asp:RequiredFieldValidator>
        </p>
        <p>
            <asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
        </p>

    </form>
</body>
</html>


wagner reatto
 
Old October 23rd, 2004, 10:17 AM
Authorized User
 
Join Date: Oct 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

sorry this is the correct code:

<%@ Page Language="VB" %>
<script runat="server">

    ' Insert page code here
    '

    Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs)
        TextBox1.enabled = not TextBox1.enabled
        TextBox2.enabled = not TextBox2.enabled
    End Sub

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            <asp:CheckBox id="CheckBox1" runat="server" OnCheckedChanged="CheckBox1_CheckedChanged" AutoPostBack="True"></asp:CheckBox>
        </p>
        <p>
            <asp:TextBox id="TextBox1" runat="server" Enabled="False"></asp:TextBox>
            <asp:TextBox id="TextBox2" runat="server" Enabled="False"></asp:TextBox>
        </p>
        <p>
            <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
        </p>
        <p>
            <asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
        </p>
        <p>
            <asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
        </p>

    </form>
</body>
</html>


wagner reatto





Similar Threads
Thread Thread Starter Forum Replies Last Post
required field validator rocksbhavesh ASP.NET 1.0 and 1.1 Basics 2 June 30th, 2007 03:20 AM
Required Field Validator Issue vivek_inos ASP.NET 1.0 and 1.1 Professional 2 September 18th, 2006 07:57 AM
Enabling and disabling Required field Validators mrufus General .NET 0 June 27th, 2006 03:44 AM
Required Field Validator RGB ASP.NET 1.0 and 1.1 Basics 3 March 31st, 2006 03:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.