display grid value using webforms in umbraco

两盒软妹~` 提交于 2019-12-12 02:49:11

问题


I am trying to display a document property in my webform template in umbraco, like this:

<%@ Master Language="C#" MasterPageFile="~/umbraco/Masterpages/Default.master" AutoEventWireup="true" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <umbraco:item field="content" runat="server" />

</asp:Content>

But on the content i am getting a json description of the field, not the value, here is the output:

{ "name": "1 column layout", "sections": [ { "grid": 12, "rows": [ { "name": "Headline", "areas": [ { "grid": 12, "hasConfig": false, "controls": [ { "value": "
This is the content i am adding

", "editor": { "alias": "rte" }, "active": true } ] } ], "hasConfig": false, "id": "31604cf5-c263-0d98-8978-67e07390adff" } ] } ] }

Image attached

How can i just display the value property?

Thanks


回答1:


Oh, you're using a Grid datatype. Then I don't think you can use the umbraco:item thingy anyways, sorry :-s

Here's a list of ways to render grid HTML, but the examples are using Razor / MVC: https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/grid-layout/render-grid-in-template

You could try something like this:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <%= CurrentPage.GetGridHtml("content") %>
</asp:Content>

If none of the examples in the list works, grids might not be supported in Web Forms. Consider using the (more modern) MVC and Razor approach instead - you could install the Fanoe starter kit on a fresh installation and see how it's done?



来源:https://stackoverflow.com/questions/36558977/display-grid-value-using-webforms-in-umbraco

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!