+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Accessing Custom Attributes of Widgets from Codebehind

Accessing Custom Attributes of Widgets from Codebehind

3 posts, 1 answered
  1. Kay
    Kay avatar
    6 posts
    Registered:
    23 Jan 2015
    23 Jan 2015
    Link to this post

    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

  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    23 Jan 2015 in reply to Kay
    Link to this post

    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.

    Answered
  3. Kay
    Kay avatar
    6 posts
    Registered:
    23 Jan 2015
    26 Jan 2015 in reply to Steve
    Link to this post

    Thanks, Steve.

    I wasn't aware that "GetString" were extension methods. Indeed I didn't include the necessary namespaces.

3 posts, 1 answered