Accessing Custom Attributes of Widgets from Codebehind
Hi,
I adapted the "News" library to allow the user to attach media files to the NewsItem.
I created a widget template to display the news item (and news list). Rendering of the news items works fine. Now I want to query the model in code behind to see whether any news were attached or not.
((Telerik.Sitefinity.News.Model.NewsItem)((Telerik.Web.UI.RadListViewDataItem)(e.Item)).DataItem)
I am able to navigate to the NewsItem (with the above code). I am seeing the Content of the NewsItem there but I don't see the custom attributes. Any hints?
Thanks,
/Kay
Do you mean like custom fields? They are defined in the DB, not part of the physical object so visual studio can't show you them...however they are still there (if this is what you mean)
Just use the syntax of .GetValue<type>("fieldname")
If you don't see getvalue make sure you have Telerik.Sitefinity, Telerik.Sitefinity.Model in your usings.
Thanks, Steve.
I wasn't aware that "GetString" were extension methods. Indeed I didn't include the necessary namespaces.