0

I have 3 User controls which have sets of questions and answers. Each usercontrol has a next button. The third user control has a submit button.

On clicking the submit button I need to trigger a required field validator in all 3 usercontrols. How can i achieve this?

3
  • The next button makes the user control to get invisible on the client side via javascript or does it become invisible via a regular postback and there the Visible property gets set in code behind? Commented Nov 20, 2011 at 17:59
  • You can get a reference to the button using ClientID property and attach a java script to each button on page load by adding an attribute i.e.: btnFirstQuestion.Attributes.Add("onclick","<your method code>");. It would be helpful if you described what exactly you have problems with ;). Commented Nov 20, 2011 at 20:48
  • In my case the next button clears the previous control from the placeholder and loads the new controls and adds it to the placeholder. Commented Nov 22, 2011 at 11:57

1 Answer 1

1

If you are using style="display:none" to hide the panels, then if you tie all the validators to the same validationgroup as the button, they will all fire. If you use server-side Visible="false", then this may still be the case, but only with server-side validation since hidden content doesn't render.

Sign up to request clarification or add additional context in comments.

3 Comments

The next button clears the previous control from the placeholder and loads the new controls and adds it to the placeholder. Is this the correct way? Can you give me an example.?
Oh, so you are dynamically validating input... here is where the challenge lies. You can't use the ASP.NET validation system to do this; instead, you have to programmably check each value from the server, and render out the errors by hand.
It would be a great help if you can share some example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.