0

I'm using Sitefinity 8.1 in MVC mode. I have an MVC page template with an assortment of placeholders.

I've created an MVC widget designed to be used multiple times on a page. From within the controller code I would like to be able to find out the name of the placeholder the widget is sitting in so that I may make adjustments to the widget on-the-fly.

Is this possible?

Thank you.

2 Answers 2

1

Instead of relying on the name of a placeholder, which I think is prone to errors, why not just introduce a public property in the controller? e.g.

public string Message {get; set;}

Then when you drop the widget in placeholder1 you can edit its properties and put whatever you want in the Message property.

Similarly, when you drop the widget in placeholder2 - you edit its properties and set something else in the Message property.

The controller will do different things depending on the value of the property - this way it is much cleaner than relying on placeholder name.

1
  • Thank you for the reply. The widget's only property is a guid to a selected custom content item. I could set another property in the widget designer but the content item itself has a handful of properties the user is already setting. In essence I want the user to be able to drop the widget in any of the placeholders, and based on which placeholder it's in different styles or classes are applied on the markup. Oct 8, 2015 at 11:57
0

Do the adjustments need to be server side? If not just make changes based on CSS selectors. If server side I'll have to get back to you.

1
  • Thank you for the reply. The solution definitely needs to be on the server side. Oct 8, 2015 at 12:00

Your Answer

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

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