Having a problem with ServerValidateEventArgs value when a Custom Validator is fired. The method that is executed is very simple. Evertime it is fired the value of ServerValidateEventArgs is always blank while debugging (the textbox does have a value in it). The code is from a web control that is inside another web control (aspx page that has control on it, and that control contains the control that doesn't validate). Both controls are using MultiViews if that matters. If I put this control and its code on a simple aspx page (one control on an aspx page) it works fine. Any ideas? Thanks for reading. protected void ValidateSecurityCode(object sender, ServerValidateEventArgs e) { if (_required) { //check to see if it has a value or not e.IsValid = !string.IsNullOrEmpty(e.Value); } else { e.IsValid = true; } } <asp:TextBox runat="server" ID="CodeTextBox" ValidationGroup="PaymentValues" EnableViewState="false"/> <asp:CustomValidator runat="server" ID="CodeCustomValidator" OnServerValidate="ValidateSecurityCode" ControlToValidate="CodeTextBox" meta:resourceKey="CodeTextBoxResource" ValidateEmptyText="true" CssClass="formValidationErrorInline" ForeColor="#db4242" ValidationGroup="PaymentValues" />
On Jul 2, 3:02 am, "zeplynne" wrote: > Having a problem with ServerValidateEventArgs value when a Custom Validator > is fired. The method that is executed is very simple. Evertime it is fired > the value of ServerValidateEventArgs is always blank while debugging (the > textbox does have a value in it). The code is from a web control that is > inside another web control (aspx page that has control on it, and that > control contains the control that doesn't validate). Both controls are > using MultiViews if that matters. If I put this control and its code on a > simple aspx page (one control on an aspx page) it works fine. Any ideas? > Thanks for reading. > > protected void ValidateSecurityCode(object sender, ServerValidateEventArgs > e) > { > if (_required) > { > //check to see if it has a value or not > e.IsValid = !string.IsNullOrEmpty(e.Value); > } > else > { > e.IsValid = true; > } > } > > <asp:TextBox runat="server" ID="CodeTextBox" ValidationGroup="PaymentValues" > EnableViewState="false"/> > <asp:CustomValidator runat="server" ID="CodeCustomValidator" > OnServerValidate="ValidateSecurityCode" > ControlToValidate="CodeTextBox" meta:resourceKey="CodeTextBoxResource" > ValidateEmptyText="true" CssClass="formValidationErrorInline" > ForeColor="#db4242" > ValidationGroup="PaymentValues" /> Hi zeplynne Not sure about your particular case, but MultiView has a ViewState problem which may cause you this: http://is.gd/KhU Tanzim Saqib http://www.TanzimSaqib.com
Hi > [...] > textbox does have a value in it). The code is from a web control that is > inside another web control (aspx page that has control on it, and that > control contains the control that doesn't validate). Both controls are > using MultiViews if that matters. If I put this control and its code on a > simple aspx page (one control on an aspx page) it works fine. Any ideas? > Thanks for reading. What kind of webcontrol are those both? Does both implement INamingContainer in case of ensure unique IDs? -- Gruss, Peter Bucher Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET