I created an Accordion component in Sitecore(web-forms) and it's working fine. But if I add multiple accordions on the same page it's opening up the first accordion even though if I click on the second one.

To resolve this I need to pass some unique ID, so I thought of passing sitecore item ID to resolve this but so far no luck.

Here's my code: (I am using asp:Repeater)

<a data-toggle="collapse" data-parent="#accordion" href="#ItemID>" >Heading</a>

Is there any way to pass the Sitecore item ID ?


You can get Sitecore Item Id on user control using below code

<a data-toggle="collapse" data-parent="#accordion" href="#<%#((Sitecore.Data.Items.Item)Container.DataItem).ID.ToShortID()%>" >

it will provide you item id on anchor tag.

  • Thank you Rishiraj, that worked perfectly.
    – Sun
    Apr 19 '20 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.