Cannot display similar web parts in one page
Anyone, I've created a web part to display a Tree Structure using jQuery from a Managed Metadata. I've created webpart properties to set certain things. Question: 1. When I tried to add the same web parts on the same page, I'm having clash issue. 2. When I modify the first webpart property, the 2nd web part properties got affected too. Any idea? M Sariman RKO Business Solutions Inc.
May 2nd, 2012 3:50pm

Difficult to tell what you've done as it's a custom web part but it would appear when you make a change on web part 1, a variable is being set that the web part 2 is also using. You need to find a way of making them independent.Paul Turner http://redmanta.co.uk/blog Twitter: @RedMantaUK MCTS:WSS,MOSS,2010 MCITP:2010. Please remember to click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.
Free Windows Admin Tool Kit Click here and download it now
May 2nd, 2012 4:02pm

I've created a simple Visual Web Part and added twice on one page. The webpart properties affects each other when modified. How to make them independent? Anything to do with personalization? private static string ServiceApp = "Managed Metadata Service"; [Category("Managed Metadata Navigation Group"), Personalizable(PersonalizationScope.Shared), WebBrowsable(true), WebDisplayName("Search Service Application Name"), WebDescription("Please Enter a Application Name")] public string _ServiceApp { get { return ServiceApp; } set { ServiceApp = value; } } M Sariman RKO Business Solutions Inc.
May 2nd, 2012 4:14pm

Hi Mohamad, As you said, you use jquery to control the Web Part display. If you want to add the Web Part twice or more on a same page, you have to make sure the id between them are not repeating. Following is a sample scenario: The jquery script: $(document).ready(function (){ $('.togglingDiv').find('dd').hide().end().find('dt').click(function() { $(this).next().slideToggle("fast"); }); }); The HTML the jquery is toggling: <dl class="togglingDiv"> <dt>Lorem ipsum</dt> <dd> Lorem ipsum dolor sit amet, consectetur adipiscing elit.</dd> <dt>Lorem ipsum</dt> <dd> Lorem ipsum dolor sit amet, consectetur adipiscing elit.</dd> <dt>Lorem ipsum</dt> <dd> Lorem ipsum dolor sit amet, consectetur adipiscing elit.</dd> </dl> You can replace <dl class="togglingDiv"> with <dl id="togglingDiv" runat="server">. When it has "runat server", Asp.net takes care of generating a different ID for each instance of your "togglingDiv". Then you put the jQuery code in an ascx file and generate it using ASP.Net's <%= .... %> construct: $(document).ready(function (){ $('#<%=togglingDiv.ClientId%>').find('dd').hide().end().find('dt').click(function() { $(this).next().slideToggle("fast"); }); }); Thanks, Lhan Han
Free Windows Admin Tool Kit Click here and download it now
May 8th, 2012 4:14am

Hi Lhan, What if I don't use jQuery. private static string ServiceApp = "Managed Metadata Service"; [Category("Managed Metadata Navigation Group"), Personalizable(PersonalizationScope.Shared), WebBrowsable(true), WebDisplayName("Search Service Application Name"), WebDescription("Please Enter a Application Name")] public string _ServiceApp { get { return ServiceApp; } set { ServiceApp = value; } }M Sariman RKO Business Solutions Inc.
May 9th, 2012 10:49am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics