CompareValidator and Autopostback

G

Guest

I have a textbox in a webform which is validated by a compare validator. Also the textbox has autopostback property set to true. When I work this way, the page immediately posts back, thus the validator has no effect

So I tried to work it this way. I set the Autopostback=false and then in the page load event I wrot
textbox1.Attributes.Add("onchange", "javascript:if((typeof(Page_ClientValidate) == 'function') && Page_ClientValidate())" + Me.GetPostBackEventReference(textbox1, "")

I also have an image button on the form. When I use the above code, and when the page shows validation error message, I will have to click the imagebutton twice to perform an action. When there is no validation error, it works with single click. Is there a way to get around this without having the user to click the imagebutton twice when the page shows validation error

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top