Summary Validation Doesn't work for Custom Vlidation Control ,Server side validation

I have many validation controls, one of which is custom validation control. All the validation controls run on client side show proper validation summary message. But for Custom validation control, the validation summary doesn't show anything which runs on server side. Why? My sample code is as follow.
protected void CusValSponsorName_ServerValidate*object source, ServerValidateEventArgs args*
    {
        string[] names = sd.getSponsorName("Select SponsorName from Sponsor");

        foreach *string name in names*
        {
            if (args.Value == name)
            {
                args.IsValid = false;
                //MessageBox.Show*"SponsorName is alreay existed, Cannot add!"*;
                //flag = false;      
            }

        }
    }
Eventhough I put the Message box, the event runs twice and show Message two times.
Is it the Bug of VS 2005 professional? If so, please give me the solutoin ASAP. Thanks
0
saukpatthanshwe
5/10/2007 4:14:16 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

1 Replies
893 Views

Similar Articles

[PageSpeed] 36

If your customvalidator evaluation function is called twice, there are a couple of reasons:

1. You are calling Page.Validate() twice. If a Button submits the page and has CausesValidation=true, it will fire once. Perhaps you are calling it a second time.

2. The ServerValidate event is attached twice to your method. Perhaps you are programmatically setting it and also using <%@ Page AutoEventWireup="true" %>.

Don't forget to test Page.IsValid is true inside your postback event handler method and skip code that would process the page's data if its false.


--- Peter Blum
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
www.PeterBlum.com
0
PLBlum
5/10/2007 5:44:03 PM
Reply:

Similar Artilces:

Can't figure out why one form causes validation on other controls and the other doesn't
I have two diffferent ASPX pages.  Both have the same regularexpressionevaluator with the same validation expression.  I have all of the controls on both pages set with causesvalidation = true.  On one page, when I am leaving a particular control, it validates all of the other controls.  On the other page, it only validates it's own control upon leaving it, and ignores the others.  I want it to ignore the others since I display the currency symbol, etc in textboxes. Any ideas of why one page is validating all controls, and the other is only validation its own co...

Validator Callout.. and required field validators
Hey guys,I have the Validator Callout working like a charm on my laptop ( Vista). However, when I Upload it to our beta server (Server 2003),  it doesn't work at all. But I think the problem might be deeper. On my laptop if I submit my form without any information in it, it validates on the client. However, on the beta, it does a postback (inside an update panel), and then tells me what fields I have missing... oh and the validator does not show up. This is the first time seeing this, and it's strange.All my other Toolkit controls work great... but this validation is j...

custom validation control client side validation did not work
<head runat="server"><script language=JavaScript >  function vrNameLenght( sender, args){  if (args.Value.Length > 15) args.IsValid = false; elseargs.IsValid = true;   }  </script> </head> <form id="form1" runat="server">                  <asp:ValidationSummary ID="ValidationSummary1" runat="server" />        <table align =center  width=750  &...

Validation summary control doesn't show errors from login control
I have set up a page with a login control.  I also added a ValidationSummary control.  The summary control's ShowMessageBox property = true; and the ValidationGroup property = the login control ID. The summary control does not show the error messages if the name or password text boxes are blank when executed.  Is there something else that has to be set up? I've run through several tutorials and a number of references without success.  Any help is greatly appreciated!     Hi,I can't reproduce your problem. Can you post your code? The below works f...

Custom validation doesn't work
Hi, I have three editable fields in a datagrid. All of them are not mandatory but atleast one of them should be entered. For this requirement i've added a customValidationControl to one of the fields. But, the problem is this function (client function in JavaScript) is not called unless until some value is entered into the field. Can anyone give me a workaround? Thanks in advance. Hey! It compiles! Ship it! Cheers, Venugopal Mallarapu. Visit : My Blog no ideas???????Hey! It compiles! Ship it! Cheers, Venugopal Mallarapu. Visit : My Blog Use a required field valid...

Can't get the Web Controls to work.. The Build.Bat file doesn't work? HELP>> ARGGG>.
Hi.. I was wanting to use the IE Web Controls, the Tab Strip, etc, and play with it.. Since I have IIS 5, I thought I'd copy them there using the Read me.txt instructions and then copy to a dev server that I use at a web host.. Well, everything worked except the Build file doesn't build the Microsoft.UI.Webcontrols.DLL file? When I try to run it by double clicking on it, it runs really fast in  the DOS window, but I can't see what it says and it closes.. So I tried to do so manually and I received an error that the "cse.exe is not recognized as an internal or external command or batch...

custom validator doesn't work in firefox
Hello.I've built a new validation control that is supposed to validate a custom datetextbox control (which i've also built). the validated control is rendered in the client as a span with 3 textboxes inside. i've also craeted a jscript object to encapsulate access to this control on the client side.the validation control works without a problem in IE. however, in firefox there's always a postback that sends the page back to the server (event though the control has invalid data). I've been trying to understand the problem, but till now i really can't see why this is happening. i think that I ...

Validation Summary Control Doesn't display
Please help me Validation Summary Control Doesn't display I had set Showmessage property to true and there is required field validator assigned to textbox. I can't think what is the problem. Hi, please post the code so we can try to replicate the error and give better answers. Use the proper tags used on these forums: view post 98065. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. Thanks for the reply. here is the sample code i am testing: **************** <asp:TextBox id="TextBox1" style="...

Client-side validation doesn't work
I'm trying to use client-side user input validation. It works fine on my computer but doesn't work on production server. I have no any error message, it just doesn't validate anything. What can be the problem? The Framework versions are the same. Hi I have exactly the same problem. In addition to: after the page post back i got the error messge of the validators displayed !! I am also using the same version (MS .net framework 1.1) on both computer , my local and the remote production server. Thanks for concern. Does the aspnet_client folder exist on the web server...

How to ignore the validation controls when you are posting the page to the server and you don't need the validation?
I have problem posting the page back asynchronously using the update panel by one asp:Button when there are some validation controls attached to some text controls on the page and the button I use to post the page back is not related to the validation. Any ideas?   Thanks for your helpMark as an answer if it helps. Set that buttons CausesValidation property to False.  Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/...

Button Doesn't Work on Panel with Validation Control
I have noticed that within my application my button controls do not work when there are validation controls on the panel (even if the validation controls are not visible, i.e. not showing an error with the control they are validating). When I click the buttons they enter the depressed state, but nothing happens. Similar button controls work fine when on a page where their is no validation. Also, I am only experiencing this issue on one out of three web servers the application is on. I have checked and the aspnet_client script directory is in the root directory of the application.www....

custom validation control procedure doesn't executes
Hi, I am using custom validation control in my web page. HTML Portion is: <asp:customvalidator id="CustomValidator2" style="Z-INDEX: 101; LEFT: 176px; POSITION: absolute; TOP: 16px" runat="server" ErrorMessage="You Must Select Business State" ControlToValidate="dplWState" OnServerValidate="valServer"></asp:customvalidator> Code Behind: Sub valServer(ByVal sender As Object, ByVal value As ServerValidateEventArgs) value.IsValid = False End Sub Private Sub btNext_Click(ByVal sender A...

CreateUserWizard
Hi folks,I am trying to add some validations controls to the second step of "CreateUserWizard" (Titled "Contact details"), but all validations failed to work. Having stuck on this for few days now sadly, so if anyone can give me some clue, will really appreciate it.P.S. Tested the original code, it doesn’t work as well, so obviously this is a bug from my point of view...Cheers,moomoonet   Validations controls inside this section never worked!!! see Member_Register.aspx. Why???  <asp:WizardStep ID="WizardStep1" runat="server" Title=&...

Validator doesn't validate
Hi, I'm using the RequiredFieldValidator control to validate my form and it works perfectly on my local machine. But as soon as I deploy my application to the server, it stops working and the form gets submitted without validation. My local setup is WinXP Pro, IIS 5, .NET 1.1 and the server setup is Win 2003, IIS 6, .NET 1.1 I've tried to troubleshoot this but can't figure out what's wrong. Thanks copy your asp_net client folder from your development box over to the server. The asp_net client folder is under your root. Another method is to run the aspnet_regIIS utilityGet ready...

Web resources about - Summary Validation Doesn't work for Custom Vlidation Control ,Server side validation - asp.net.web-forms

Resources last updated: 12/15/2015 4:50:09 PM