Answered by:
issue adding custom webpart twice on a page

Question
-
hello ,
i have developed a custom webpart "MyWebPart" using visual studio and i have a issue when adding my custom webpart twice on a page , the first webpart display correctly but the second instance of the webpart is not displaying , i see only the title like this : MyWebPart(2) and the title of the first webpart become MyWebPart(1).
Any help will be appreciated.
Thanks
Monday, June 29, 2015 9:47 AM
Answers
-
If it references a user control that's probably the issue. You would need to make sure in your code that you loaded the user control as two separate instances of the user control. Otherwise it will either only load once or load twice and display the same thing.
Paul Stork SharePoint Server MVP
Principal Architect: Blue Chip Consulting Group
Blog: http://dontpapanic.com/blog
Twitter: Follow @pstork
Please remember to mark your question as "answered" if this solves your problem.Monday, June 29, 2015 4:31 PM
All replies
-
Web parts need to be specifically written to support multiple instances of a web part on the same page. What you need to do to support multiple instances depends on what the web part is trying to display. What you are seeing is normal for most web parts.
Paul Stork SharePoint Server MVP
Principal Architect: Blue Chip Consulting Group
Blog: http://dontpapanic.com/blog
Twitter: Follow @pstork
Please remember to mark your question as "answered" if this solves your problem.Monday, June 29, 2015 10:23 AM -
my webpart is used to display images from a sharepoint library.Monday, June 29, 2015 11:32 AM
-
The real question is what is this web part doing? My guess would be you are referrencing controls in a less than correct way.Monday, June 29, 2015 11:39 AM
-
the webpart reference a user control and use a editorPart.Monday, June 29, 2015 11:56 AM
-
If it references a user control that's probably the issue. You would need to make sure in your code that you loaded the user control as two separate instances of the user control. Otherwise it will either only load once or load twice and display the same thing.
Paul Stork SharePoint Server MVP
Principal Architect: Blue Chip Consulting Group
Blog: http://dontpapanic.com/blog
Twitter: Follow @pstork
Please remember to mark your question as "answered" if this solves your problem.Monday, June 29, 2015 4:31 PM