Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dev-91 5 posts 75 karma points
    Jan 14, 2017 @ 07:18
    Dev-91
    0

    How to fetch Settings.Properties.PropertyType.

    Hi, I have a requirement that On language change user should be kept on same page. Therefore, I am trying to get all PropertyTypes under Settings. Then I'll fetch ContentID of setting record that stores current page url. Then I'll get other Setting records for that ContentID.

    But here I am stuck that I can't fetch PropertyType under Setting.Properties. I am executing following code:

    var settingsPage = CurrentPage.AncestorOrSelf(1).Descendants("settings").FirstOrDefault();
    
    foreach (var curP in settingsPage.Properties)
    {
        var m = curP.PropertyType;
    }
    

    And It's generating following exception:

    'object' does not contain a definition for 'PropertyType'
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'object' does not contain a definition for 'PropertyType'
    
    Source Error: 
    
    
    Line 12:     foreach (var curP in settingsPage.Properties)
    Line 13:     {
    Line 14:         var m = curP.PropertyType;
    Line 15:     }
    Line 16:     @*foreach (var curP in settingsPage.Properties)
    
Please Sign in or register to post replies

Write your reply to:

Draft