Valdiation Behaviour

  • Thread starter Thread starter Eldon Ferran de Pol
  • Start date Start date
E

Eldon Ferran de Pol

Hi all,

I've got a CompareValidator comparing the value of one
drop down against another this works without any problems
except that whenever another control on my page with
AutoPostBack set to true is fired the validation error
message is lost.

I have tried testing postback in my Page_Load event and
then called Page.Validate but this has had no effect.

Any ideas as to what may be causing this.

Cheers,

Eldon
 
I am not sure what you are asking, but am wondering
whether you can use a validation summary control to
display all the messages from the validation controls?

-Shan
 
If you View Source on the page, you will see several things:
1. The TextBox uses onchange = "__doPostBack"
2. The "__doPostBack" function is declared
3. The validation submission code is present on the page.
4. The onchange= code doesn't call the validation submission code.
The task is make AutoPostBack call the validation submission code. The
AutoPostBack doesn't do that for you. Here's how to make it work.
1. Set AutoPostBack to false.
2. Add this statement in Page_Load, which is the same scripting code as
AutoPostBack uses plus the validation code (shown in C#):
TextBox1.Attributes.Add("onchange", "javascript:if
((typeof(Page_ClientValidate) == 'function') && Page_ClientValidate())" +
this.GetPostBackEventReference(TextBox1, ""));

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
 
Back
Top