Question

My problem precisely and concisely is that I developed a simple web part to display OOTB Surveys on the page (Which means user can answer and submit the survey through my web part). It works correctly.

BUT when I add the web part two times, then, User will not be able to submit any of them. Simply because when s/he answer the first survey and click Submit-Button, the required field validation will fire on the other web part and requesting to be filled.

Scenario: (I hope those steps give you better understanding of my case)

1- Assume that I add my SurveyViewer web part to display Voting on the right side of the page. Also, I added again my SurveyViewer web part to display Quiz.

2- The user opened the page and s/he only wants to Vote, So s/he selects and clicks Vote.

3- Nothing gets submitted and the Page will display “Please fill the fields of Quiz”.

Question: How can I submit the Voting without being affected by other instances?

Thank you, and I would greatly appreciate your inputs!

Was it helpful?

Solution

There are various issues which could be at play here, but essentially you can solve your validation issue by ensuring that the ValidationGroup property of your validation controls is unique to a given instance of your webpart (maybe prefix it with the ClientID property.)

You will need to ensure that your sumbit button is set to not cause validation explicitly and then ensure that when it is clicked you call Validate() and pass in the name of your validation group.

This should fix this issue but not other issues related to multiple instances.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top