1

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 ?

1 Answer 1

6

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.

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

Your Answer

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

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