DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 8 Aug 2007 16:26:03 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Bill
          2    Joey
                 3    Bill


Validation Groups - Server side   
Ok, so I'm working through examples in the apress book "Pro ASP.NET 2.0 in C# 
2005". The Validation groups example doesn't work the way I thought it 
should.  It consists of 2 textboxes and 2 buttons and 2 required field 
validators.  One set of controls is set to validation group "G1" and the 
other set to "G2".  There is also a label to display what happens on the 
server.

The example appears to work flawlessly at the browser but results at the 
server vary.  Specifically, leave the first textbox empty and enter text in 
the 2nd textbox (group "G2" controls) and click it's Validate button. The 
page posts back and the server reports that both groups evaluate to false.  I 
had expected The "G2" contol to evaluate to true.  Am I missing somrthing 
here?  See below for the HTML and code behind.

Bill



<%@ Page Language="C#" AutoEventWireup="true" 
CodeFile="10ValidationGroups.aspx.cs" 
Inherits="Ch04ServerControls_10ValidationGroups" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Validation Groups</title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="font-size: 16pt; color: #0000cc">
        Pro ASP.NET 2.0 in C#<br />
        Chapter 4, Page 144<br />
        <hr style="color: #ff0099; height: 5px" />
         Web Controls - Validation Groups
        <br />
         <asp:HyperLink ID="HyperLink1" runat="server" font-size="10pt" 
NavigateUrl="~/Default.aspx">[Home]</asp:HyperLink>
         <br />
         <br />
    </div>
    <div>
        <asp:Panel ID="Panel1" runat="server" Height="67px" Width="281px">
            <asp:TextBox ID="TextBox1" runat="server" ValidationGroup="G1" 
Width="229px"></asp:TextBox><br />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" 
runat="server" ErrorMessage="*Required."
                Width="185px" ControlToValidate="TextBox1" 
ValidationGroup="G1"></asp:RequiredFieldValidator><br />
            <asp:Button ID="Button1" runat="server" Text="Validate Group 1" 
ValidationGroup="G1"
                Width="139px" OnClick="ValidatAll_Click" /></asp:Panel>
         <br />
         
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
        <br />
        <asp:Panel ID="Panel2" runat="server" Height="67px" Width="281px">
            <asp:TextBox ID="TextBox2" runat="server" ValidationGroup="G2" 
Width="230px"></asp:TextBox><br />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" 
runat="server" ErrorMessage="*Required."
                Width="186px" ControlToValidate="TextBox2" 
ValidationGroup="G2"></asp:RequiredFieldValidator><br />
            <asp:Button ID="Button2" runat="server" Text="Validate Group 2" 
ValidationGroup="G2"
                Width="139px" OnClick="ValidatAll_Click" /></asp:Panel>
    </div>
    </form>
</body>
</html>




using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Ch04ServerControls_10ValidationGroups : 
System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void ValidatAll_Click(object sender, EventArgs e)
    {
        Label1.Text = "Valid: " + Page.IsValid.ToString();
        Page.Validate("G1");
        Label1.Text += "<br/>Group 1 Valid: " + Page.IsValid.ToString();
        Page.Validate("G2");
        Label1.Text += "<br/>Group 2 Valid: " + Page.IsValid.ToString();
    }
}
Date:Wed, 8 Aug 2007 16:26:03 -0700   Author:  

Re: Validation Groups - Server side   
On Aug 8, 6:26 pm, Bill  wrote:

> Ok, so I'm working through examples in the apress book "Pro ASP.NET 2.0 in C#
> 2005". The Validation groups example doesn't work the way I thought it
> should.  It consists of 2 textboxes and 2 buttons and 2 required field
> validators.  One set of controls is set to validation group "G1" and the
> other set to "G2".  There is also a label to display what happens on the
> server.
>
> The example appears to work flawlessly at the browser but results at the
> server vary.  Specifically, leave the first textbox empty and enter text in
> the 2nd textbox (group "G2" controls) and click it's Validate button. The
> page posts back and the server reports that both groups evaluate to false.  I
> had expected The "G2" contol to evaluate to true.  Am I missing somrthing
> here?  See below for the HTML and code behind.
>
> Bill
>
> <%@ Page Language="C#" AutoEventWireup="true"
> CodeFile="10ValidationGroups.aspx.cs"
> Inherits="Ch04ServerControls_10ValidationGroups" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
>     <title>Validation Groups</title>
> </head>
> <body>
>     <form id="form1" runat="server">
>     <div style="font-size: 16pt; color: #0000cc">
>         Pro ASP.NET 2.0 in C#<br />
>         Chapter 4, Page 144<br />
>         <hr style="color: #ff0099; height: 5px" />
>          Web Controls - Validation Groups
>         <br />
>          <asp:HyperLink ID="HyperLink1" runat="server" font-size="10pt"
> NavigateUrl="~/Default.aspx">[Home]</asp:HyperLink>
>          <br />
>          <br />
>     </div>
>     <div>
>         <asp:Panel ID="Panel1" runat="server" Height="67px" Width="281px">
>             <asp:TextBox ID="TextBox1" runat="server" ValidationGroup="G1"
> Width="229px"></asp:TextBox><br />
>             <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
> runat="server" ErrorMessage="*Required."
>                 Width="185px" ControlToValidate="TextBox1"
> ValidationGroup="G1"></asp:RequiredFieldValidator><br />
>             <asp:Button ID="Button1" runat="server" Text="Validate Group 1"
> ValidationGroup="G1"
>                 Width="139px" OnClick="ValidatAll_Click" /></asp:Panel>
>          <br />
>
>         <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
>         <br />
>         <asp:Panel ID="Panel2" runat="server" Height="67px" Width="281px">
>             <asp:TextBox ID="TextBox2" runat="server" ValidationGroup="G2"
> Width="230px"></asp:TextBox><br />
>             <asp:RequiredFieldValidator ID="RequiredFieldValidator2"
> runat="server" ErrorMessage="*Required."
>                 Width="186px" ControlToValidate="TextBox2"
> ValidationGroup="G2"></asp:RequiredFieldValidator><br />
>             <asp:Button ID="Button2" runat="server" Text="Validate Group 2"
> ValidationGroup="G2"
>                 Width="139px" OnClick="ValidatAll_Click" /></asp:Panel>
>     </div>
>     </form>
> </body>
> </html>
>
> using System;
> using System.Data;
> using System.Configuration;
> using System.Collections;
> using System.Web;
> using System.Web.Security;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.WebControls.WebParts;
> using System.Web.UI.HtmlControls;
>
> public partial class Ch04ServerControls_10ValidationGroups :
> System.Web.UI.Page
> {
>     protected void Page_Load(object sender, EventArgs e)
>     {
>     }
>     protected void ValidatAll_Click(object sender, EventArgs e)
>     {
>         Label1.Text = "Valid: " + Page.IsValid.ToString();
>         Page.Validate("G1");
>         Label1.Text += "<br/>Group 1 Valid: " + Page.IsValid.ToString();
>         Page.Validate("G2");
>         Label1.Text += "<br/>Group 2 Valid: " + Page.IsValid.ToString();
>     }
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -


Double check your control-to-validate property for each. Make sure
that for rfv1 its set to txt1 and for rfv2 its set to txt2. Also,
double check the validation group properties for both validators, both
buttons, and both validation summaries. You do not have to set it for
the textboxes.

I have just recently figured how to use validations groups and also
custom validators. Once you figure out how to insert custom logic into
both the client-side and server-side custom validation functions
(unless you already have), you will find that life is MUCH EASIER!!!
Date:Thu, 09 Aug 2007 07:26:07 -0700   Author:  

Re: Validation Groups - Server side   
Ok, so all the stuff you mentioned to check is set correctly as you can see 
by the code I included.  Yet the server continues to return false for 
validation group G2 given the conditions I described in my original post.  So 
the question remains, is there a problem with my code, or is there a problem 
with the way validation groups work at the server?  

Bill


"Joey" wrote:


> On Aug 8, 6:26 pm, Bill  wrote:
> > Ok, so I'm working through examples in the apress book "Pro ASP.NET 2.0 in C#
> > 2005". The Validation groups example doesn't work the way I thought it
> > should.  It consists of 2 textboxes and 2 buttons and 2 required field
> > validators.  One set of controls is set to validation group "G1" and the
> > other set to "G2".  There is also a label to display what happens on the
> > server.
> >
> > The example appears to work flawlessly at the browser but results at the
> > server vary.  Specifically, leave the first textbox empty and enter text in
> > the 2nd textbox (group "G2" controls) and click it's Validate button. The
> > page posts back and the server reports that both groups evaluate to false.  I
> > had expected The "G2" contol to evaluate to true.  Am I missing somrthing
> > here?  See below for the HTML and code behind.
> >
> > Bill
> >
> > <%@ Page Language="C#" AutoEventWireup="true"
> > CodeFile="10ValidationGroups.aspx.cs"
> > Inherits="Ch04ServerControls_10ValidationGroups" %>
> >
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> >
> > <html xmlns="http://www.w3.org/1999/xhtml" >
> > <head runat="server">
> >     <title>Validation Groups</title>
> > </head>
> > <body>
> >     <form id="form1" runat="server">
> >     <div style="font-size: 16pt; color: #0000cc">
> >         Pro ASP.NET 2.0 in C#<br />
> >         Chapter 4, Page 144<br />
> >         <hr style="color: #ff0099; height: 5px" />
> >          Web Controls - Validation Groups
> >         <br />
> >          <asp:HyperLink ID="HyperLink1" runat="server" font-size="10pt"
> > NavigateUrl="~/Default.aspx">[Home]</asp:HyperLink>
> >          <br />
> >          <br />
> >     </div>
> >     <div>
> >         <asp:Panel ID="Panel1" runat="server" Height="67px" Width="281px">
> >             <asp:TextBox ID="TextBox1" runat="server" ValidationGroup="G1"
> > Width="229px"></asp:TextBox><br />
> >             <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
> > runat="server" ErrorMessage="*Required."
> >                 Width="185px" ControlToValidate="TextBox1"
> > ValidationGroup="G1"></asp:RequiredFieldValidator><br />
> >             <asp:Button ID="Button1" runat="server" Text="Validate Group 1"
> > ValidationGroup="G1"
> >                 Width="139px" OnClick="ValidatAll_Click" /></asp:Panel>
> >          <br />
> >
> >         <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
> >         <br />
> >         <asp:Panel ID="Panel2" runat="server" Height="67px" Width="281px">
> >             <asp:TextBox ID="TextBox2" runat="server" ValidationGroup="G2"
> > Width="230px"></asp:TextBox><br />
> >             <asp:RequiredFieldValidator ID="RequiredFieldValidator2"
> > runat="server" ErrorMessage="*Required."
> >                 Width="186px" ControlToValidate="TextBox2"
> > ValidationGroup="G2"></asp:RequiredFieldValidator><br />
> >             <asp:Button ID="Button2" runat="server" Text="Validate Group 2"
> > ValidationGroup="G2"
> >                 Width="139px" OnClick="ValidatAll_Click" /></asp:Panel>
> >     </div>
> >     </form>
> > </body>
> > </html>
> >
> > using System;
> > using System.Data;
> > using System.Configuration;
> > using System.Collections;
> > using System.Web;
> > using System.Web.Security;
> > using System.Web.UI;
> > using System.Web.UI.WebControls;
> > using System.Web.UI.WebControls.WebParts;
> > using System.Web.UI.HtmlControls;
> >
> > public partial class Ch04ServerControls_10ValidationGroups :
> > System.Web.UI.Page
> > {
> >     protected void Page_Load(object sender, EventArgs e)
> >     {
> >     }
> >     protected void ValidatAll_Click(object sender, EventArgs e)
> >     {
> >         Label1.Text = "Valid: " + Page.IsValid.ToString();
> >         Page.Validate("G1");
> >         Label1.Text += "<br/>Group 1 Valid: " + Page.IsValid.ToString();
> >         Page.Validate("G2");
> >         Label1.Text += "<br/>Group 2 Valid: " + Page.IsValid.ToString();
> >     }
> >
> >
> >
> > }- Hide quoted text -
> >
> > - Show quoted text -
> 
> Double check your control-to-validate property for each. Make sure
> that for rfv1 its set to txt1 and for rfv2 its set to txt2. Also,
> double check the validation group properties for both validators, both
> buttons, and both validation summaries. You do not have to set it for
> the textboxes.
> 
> I have just recently figured how to use validations groups and also
> custom validators. Once you figure out how to insert custom logic into
> both the client-side and server-side custom validation functions
> (unless you already have), you will find that life is MUCH EASIER!!!
> 
> 
Date:Thu, 9 Aug 2007 09:36:03 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us