简体   繁体   English

从Sitefinity中的动态模块获取自定义属性

[英]Get Custom Property from Dynamic Module in Sitefinity

How Can I get a custom Property like Title from a module I created in Module Builder? 如何从我在Module Builder中创建的模块中获取自定义属性(如Title)?

I am using this method to retreive the module instance 我正在使用此方法检索模块实例

 public static DynamicContent RetrievePollquestionByID(string guidID)
    {


        DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
        Type pollquestionType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Poll.Pollquestion");
        Guid pollquestionID = new Guid(guidID);


        DynamicContent pollquestionItem = dynamicModuleManager.GetDataItem(pollquestionType, pollquestionID);
        return pollquestionItem;

I want to retreive the Title property of the DynamicContent. 我想检索DynamicContent的Title属性。

thanks. 谢谢。

pollquestionItem.GetValue<string>("Title") or pollquestionItem.GetValue("Title") pollquestionItem.GetValue<string>("Title")pollquestionItem.GetValue("Title")

You can see a complete code example through the sitefintiy UI. 您可以通过sitefintiy UI看到完整的代码示例。

Administration >> Module Builder >> Pollquestion (the name of your Module) >> Code Reference 管理>>模块生成器>>提问(模块名称)>>代码参考

Happy Coding This! 祝您编码愉快!

Add using Telerik.Sitefinity.Model; using Telerik.Sitefinity.Model;添加using Telerik.Sitefinity.Model; as a reference and then you will be able to use get and set methods. 作为参考,然后您将可以使用get和set方法。 For example pollquestionItem.GetValue("Title") and pollquestionItem.SetValue("Title", "YourTitle") 例如pollquestionItem.GetValue("Title")pollquestionItem.SetValue("Title", "YourTitle")

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM