Published on

How to get the saved Controller properties for a widget on a page

Authors

You might find it handy to want to know what the public property data is on a widget (Mvc Controller) sitting on a page. Like perhaps you need to pull in the data over a webservice. Doesn’t matter, I’m not here to speculate on what your needs are!

Here’s the code:

Very very important note though. The database only stores CHANGED properties.

So lets say you have a public property called Title

public string Title { get;set; } = "Some title";

The above code snippet will not return a property called Title in the array unless you have edited the widget and changed the Title to something other than “Some title”. So you’ll need to read the defaults from the Controller if what you need isn’t there.

You can get the widgets (Controllers) control id with the ViewData

this.ViewData["controlDataId"]

Boost your online presence.

Let us create the perfect digital experience for your company.

Contact us now