Client Side Validation is Not Happening

G

Guadala Harry

I hope this is something I can solve without contacting the vendor:
I'm implementing a 3rd party component that will, by itself, initiate a
PostBack. Apparently it does not support the CausesValidation property - so
forms get posted back without any client-side validation. I know I can do
validation server side (and do anyway just as a good practice), but I want
this control (which is basically an ImageButton) to trigger client-side
validation.

This is how the 3rd party component appears in the rendered HTML (via View
Source from IE):

<a id="_ctl0:_ctl2:MyButton"
href="javascript:__doPostBack('_ctl0$_ctl2$MyButton,'')"><img
id="_ctl0__ctl2_MyButton" CausesValidation="True"
src="http://images.somesite.org/images/clickhere.gif" alt="" border="0"
/></a>

You can see that I added CausesValidation="True" but still no client side
validation.

FWIW: ASP.NET 1.1 and I'm using just the standard ASP.NET validators
(required field - nothing tricky). Also, on the same form I have a standard
asp:Button that, when clicked, does cause the validation as expected - so I
know that the validator is working as expected.

Thanks!
 
G

Guest

if the control doesnt support it you are most likely out of luck.
You MAY be able to wrap their control into your own (inheriting from theirs)
and adding the necessary functionality, but that would be a lot of work (and
possibly illegal depending on the control).
 
B

Bruce Barker

you have to change the rendered html. the control is supposed to check the
if it causes validation and change its client postback code (by calling
GetClientValidatedPostback). so it should have rendered like:

<a id="_ctl0:_ctl2:MyButton"
href="javascript:{if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate())__doPostBack('_ctl0$_ctl2$MyButton,'')}">
<img id="_ctl0__ctl2_MyButton" CausesValidation="True"
src="http://images.somesite.org/images/clickhere.gif" alt="" border="0"
/>
</a>


-- bruce (sqlwork.com)
 
G

Guadala Harry

Thanks Bruce and Curt;
I don't think the vendor would really care (PayPal provides it for free in
their .NET SDK which is apparently unaware of validation and other
ASP.NET-specific features). I'd like to take a shot at making it happen as
you suggested was possible and I don't mind writing some code. I have never
extended an existing control, much less someone elses. Can you or someone
else here give me some high-level direction to cut down on some of the
research I'm going to do on this?

Apparently PayPal wouldn't care if we extended their stuff - as can be seen
from this thread in their free NG regarding same topic.
http://paypal.forums.liveworld.com/...003272&messageID=100015819&start=-1#100015819

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top