locked
Custom Required Field Validator - problem after problem RRS feed

  • Question

  • User1189380964 posted

    I have a custom TextBox and a Custom RequiredFieldValidator. The custom RequiredFieldValidator inherit from RequiredFieldValidator. In the custom TextBox I have a Boolean property called "Required". So if this property is set from the MarkUp I will create an instance of the CustomRequiredFieldValidator in the custom TextBox class. Every thing is working fine except that I am unable to figureout where and how to check the IsValid property of custom RequiredFieldValidator.

    Also I am unable to figure out that why protected override bool EvaluateIsValid() is not executing.Please note that I have set all the required properties in the constructor of custom RequiredFieldValidator calss as following

    this.Enabled = true;
    this.Visible = true;

    I also placed an Asp Button with CauseValidation="true"; but still the page post back is not occuring. Also the click event of the Button is not executing. What I understand that all this validation is happening on the client side.


    my objective is to execute some Business Logic based on either the user has entered value in the custom Textbox or not.

    Thursday, September 24, 2009 10:52 PM

All replies

  • User-126244515 posted

    Which methods are you overloading in your custom RequiredFieldValidator? If the button isn't submitiing to the server, the EvaluateIsValid will not be executing. When you say everything is working as expected, I assume the client-side validation works, or what it exactly does work?

    my objective is to execute some Business Logic based on either the user has entered value in the custom Textbox or not.

    I assume that this business logic is on the server, right?

    Friday, September 25, 2009 4:39 AM
  • User1189380964 posted

    First thanks that some one is there to help me.

    I am overriding the following methods in my custom RequirdFieldValidator class

    1. protected override bool ControlPropertiesValid()

    2. public override Control FindControl(string id)

    3. protected override bool EvaluateIsValid()

    Also you are right that the business logic is on the server side.

    Ok - what I found that if execute the Validate() method of the custom RequiredFieldValidator then EvaluateIsValid() is called/executed. But I want this method to be executed when the button is clicked i.e. on post back, but the dilema is that but does not cause the page to post back.

    I will wait for your response and till that time will contine my work until I reach a absolute conclusion.

    <input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">

    Friday, September 25, 2009 8:13 PM
  • User1189380964 posted

    Let me share with you some more findings as following:

    1. If the InitialValue is not set the Click event for Button will not hit, i.e. no post back. Even if set the property InitialValue=String.empty; still the post back will not occur

    2. The EvaluateIsValid() is executed if and only if we call the Validate() method of the custom RequiredFieldValidator

    3. Intrestingly the InitialValue will not appear in the TextBox i.e. the control to validate.



    <input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">

    Friday, September 25, 2009 9:38 PM
  • User-2106054853 posted

     Hi,

    Could you share a demo that can demonstrate your scenario? Please upload the demo to http://skydrive.live.com/ and paste the download link here.

    Sunday, September 27, 2009 10:23 PM