Groups | Blog | Home
all groups > asp.net webcontrols > july 2003 >

asp.net webcontrols : client and server validators not firing in aspx 1.1


Bernard Borsu
7/11/2003 5:17:47 PM
I've a project who's works fine on a website with asp.net 1.0. All
validators work fine.
I've copied all the pages from this project to another website. I've
associated this new website with asp.net 1.1 with aspnet_regiis. I've open a
new project in VS 2003 and I compiled it.

A simple requiredfieldvalidator doesn't work. Neither on the client side,
neither on the server side !

Any idea ?

--
Bernard
bernard.borsu@odysseos.net

Victor Garcia Aprea [MVP]
7/11/2003 9:51:14 PM
Hi Bernard,

Is it firing any client-side errors? Very strange that its not validating at
the server-side. Could you post a super small project to repro this?

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.

[quoted text, click to view]

Bernard Borsu
7/14/2003 5:54:50 PM
Sorry for "small" but may page is quiet big :

aspx page :

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Membre.aspx.vb"
Inherits="Membre" %>
<h1 id="oTFiche" runat="server">Fiche</h1>
<h2 id="oTMode" runat="server">Modification</h2>
<table>
<tr>
<td width="160"></td>
<td><asp:validationsummary id="oVS" DisplayMode="List"
Runat="server"></asp:validationsummary></td>
</tr>
<tr>
<td>Nom</td>
<td><asp:textbox id="oNom" Runat="server"
Width="200px"></asp:textbox><asp:requiredfieldvalidator id="oRFVNom"
Runat="server" text="&amp;#9668;" ErrorMessage="Le nom est manquant."
ControlToValidate="oNom"></asp:requiredfieldvalidator></td>
</tr>
<tr>
<td>Prénom</td>
<td><asp:textbox id="oPrenom" Runat="server"
Width="200px"></asp:textbox><asp:requiredfieldvalidator id="oRFVPrenom"
Runat="server" text="&amp;#9668;" ErrorMessage="Le prénom est manquant."
ControlToValidate="oPrenom"></asp:requiredfieldvalidator></td>
</tr>
<tr>
<td>Sexe</td>
<td><asp:dropdownlist id="oSexe" Runat="server"></asp:dropdownlist></td>
</tr>
<tr>
<td>Adresse</td>
<td><asp:textbox id="oAdresse" Runat="server"
Width="254px"></asp:textbox></td>
</tr>
<tr>
<td>C.P. &amp; Localité</td>
<td><asp:textbox id="oCP" Runat="server"
Width="50px"></asp:textbox>&nbsp;<asp:textbox id="oLoc" Runat="server"
Width="200px"></asp:textbox></td>
</tr>
<tr>
<td>Téléphone</td>
<td><asp:textbox id="oTel" Runat="server"
Width="150px"></asp:textbox></td>
</tr>
<tr>
<td>EMail</td>
<td><asp:textbox id="oEMail" Runat="server"
Width="400px"></asp:textbox></td>
</tr>
<tr>
<td>EMail parent</td>
<td><asp:textbox id="oEMailParent" Runat="server"
Width="400px"></asp:textbox></td>
</tr>
<tr id="oTRType" visible="False" runat="server">
<td>Type</td>
<td>
<script language="javascript">
function ChangeType() {
document.all("oSection").disabled = event.srcElement.value > 3;
}
</script>
<asp:DropDownList ID="oType" DataTextField="Type_Nom"
DataValueField="Type_Id" onchange="javascript:ChangeType();"
Runat="server" /></td>
</tr>
<tr id="oTRSection" visible="False" runat="server">
<td>Section</td>
<td><asp:DropDownList ID="oSection" DataTextField="Anim_Nom"
DataValueField="Anim_Id" Runat="server" /></td>
</tr>
<tr id="oTRTotem" runat="server">
<td>Totem</td>
<td><asp:TextBox ID="oTotem" Width="200px" Runat="server" /></td>
</tr>
<tr>
<td>Naissance (jj/mm/aa)</td>
<td><asp:TextBox ID="oNaissance" Width="80px" Runat="server"
/><asp:CustomValidator ID="oCVNaissance" EnableClientScript="False"
ErrorMessage="La date de naissance est incorrecte."
OnServerValidate="CtrlNaissance" text="&amp;#9668;" Runat="server"
/></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td></td>
<td><asp:Button ID="oOK" CommandName="=" OnCommand="Action"
Text="Enregistrer" Width="100px" Runat="server" />
<asp:Button ID="oKO" CausesValidation="False" CommandName="0"
OnCommand="Action" Text="Annuler"
Width="100px" Runat="server" /></td>
</tr>
</table>
<asp:Literal ID="oScript" EnableViewState="False" Runat="server" />


and code behind page :

Imports System.Web.UI.WebControls

Public Class Membre
Inherits PageGestion

Protected WithEvents oNom As System.Web.UI.WebControls.TextBox
Protected WithEvents oPrenom As System.Web.UI.WebControls.TextBox
Protected WithEvents oSexe As System.Web.UI.WebControls.DropDownList
Protected WithEvents oAdresse As System.Web.UI.WebControls.TextBox
Protected WithEvents oCP As System.Web.UI.WebControls.TextBox
Protected WithEvents oLoc As System.Web.UI.WebControls.TextBox
Protected WithEvents oTel As System.Web.UI.WebControls.TextBox
Protected WithEvents oEMail As System.Web.UI.WebControls.TextBox
Protected WithEvents oOK As System.Web.UI.WebControls.Button
Protected WithEvents oKO As System.Web.UI.WebControls.Button
Protected WithEvents oTotem As System.Web.UI.WebControls.TextBox
Protected WithEvents oVS As System.Web.UI.WebControls.ValidationSummary
Protected WithEvents oRFVNom As
System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents oRFVPrenom As
System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents oNaissance As System.Web.UI.WebControls.TextBox
Protected WithEvents oCVNaissance As
System.Web.UI.WebControls.CustomValidator
Protected WithEvents oTFiche As
System.Web.UI.HtmlControls.HtmlGenericControl
Protected WithEvents oTMode As
System.Web.UI.HtmlControls.HtmlGenericControl
Protected WithEvents oTRTotem As System.Web.UI.HtmlControls.HtmlTableRow
Protected WithEvents oEMailParent As System.Web.UI.WebControls.TextBox
Protected WithEvents oType As System.Web.UI.WebControls.DropDownList
Protected WithEvents oSection As System.Web.UI.WebControls.DropDownList
Protected WithEvents oTRType As System.Web.UI.HtmlControls.HtmlTableRow
Protected WithEvents oTRSection As
System.Web.UI.HtmlControls.HtmlTableRow
Protected WithEvents oScript As System.Web.UI.WebControls.Literal

Private lNouveau As Boolean

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
lNouveau = (Request.QueryString("IdMbr") = "")

If Not IsPostBack Then
If lNouveau Then
If Niveau < 3 Then
Response.Redirect("/Gestion")
End If
Else
If BD.Requete("SELECT * FROM Membres WHERE Mbr_Id = " &
Request.QueryString("IdMbr"), "Membre").Rows.Count <> 1 Then
Response.Redirect("/Gestion")
End If
End If
End If
End Sub

Sub action(ByVal Source As Object, ByVal e As CommandEventArgs)
If e.CommandName = "=" Then
Page.Validate

If Not Page.IsValid Then
Exit Sub
End If

Dim oDate

If oNaissance.Text <> "" Then
oDate = CDate(oNaissance.Text)
End If

If BD.MAJ(lNouveau, _
"Membres", _
"Mbr_Id = " & Request.QueryString("IdMbr"), _

"Mbr_Nom·Mbr_Prenom·Mbr_Feminin·Mbr_Adresse·Mbr_CP·Mbr_Localite·Mbr_Telephon
e·Mbr_EMail·Mbr_EMailParent·Mbr_Totem·Mbr_Naissance" _
& IIf(lNouveau, "·Mbr_Type·Mbr_Animation", ""), _
oNom, _
oPrenom, _
oSexe.SelectedIndex, _
oAdresse, _
oCP, _
oLoc, _
oTel, _
oEMail, _
oEMailParent, _
oTotem, _
oDate, _
oType, _
Victor Garcia Aprea [MVP]
7/14/2003 10:17:47 PM
Hi Bernard,

Thats quite big! :)
Also it has sql code embedded which will make it impossible to repro it on
my side. You could try to reduce the code, by starting to remove
non-relevant code, while still trying to repro the problem. Usually this
exercise would give you some hints about what may be going wrong.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.

[quoted text, click to view]
Bernard Borsu
7/15/2003 11:14:56 AM
Thanks !

I will try to test my code by reducing it step by step.

I've noticed in another project that I've also transferred in asp.net 1.1
and VS 2003, that a page with a simple textbox with a requiredfieldvalidator
works fine !

"Victor Garcia Aprea [MVP]" <vga@NOobiesSPAM.com> a écrit dans le message de
news:OCnef7mSDHA.2248@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]
AddThis Social Bookmark Button