简体   繁体   English

如何使用 ASP.NET Razor 页面从 cshtml 中的 ParseObject 呈现自定义字段值?

[英]How can I render custom field values from a ParseObject in cshtml using ASP.NET Razor Pages?

I'm using Razor Pages with ASP.NET to render data to my cshtml:我正在使用带有 ASP.NET 的 Razor Pages 将数据呈现到我的 cshtml:

@* Iterate over Yeet collection *@
@foreach (var yeet in Model.YeetsList)
{
    <p>@yeet.Keys.1.value</p><br />
}

I'm iterating over a List called YeetsList that contains some ParseObject objects.我正在迭代一个名为 YeetsList 的列表,其中包含一些 ParseObject 对象。

ParseObjects don't have the custom field accessors one would need to render anything more than basic ParseObject data such as ObjectId, CreatedAt, UpdatedAt, etc., but I figured I could just render these (private) fields anyway by printing the value of the Key I want according to this: ParseObjects 没有自定义字段访问器,除了基本的 ParseObject 数据(例如 ObjectId、CreatedAt、UpdatedAt 等)之外,我还需要呈现任何内容,但我认为无论如何我都可以通过打印我想要的关键是:

在此处输入图片说明

I get the following:我得到以下信息:

在此处输入图片说明

What I want is the actual value of "notificationText".我想要的是“notificationText”的实际值。 How can I retrieve this and render it without going through the hassle of creating a local data model?如何在不经历创建本地数据模型的麻烦的情况下检索并呈现它? I really don't want to create a proper app at the moment.我现在真的不想创建一个合适的应用程序。 I just want to print the value of "notificationText" that is contained in the object.我只想打印对象中包含的“notificationText”的值。

You can use something like this , this might help你可以使用这样的东西,这可能会有所帮助

   @foreach (var yeet in Model.YeetsList)
    {
       @foreach (string key in yeet.Keys)
        {
           <p>@yeet[key].value</p><br />
        }    
    }

暂无
暂无

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

相关问题 从ASP.NET Razor CSHTML文件渲染HTML文件 - Render html files from ASP.NET Razor cshtml files 如何从 ASP.NET Razor 页面中的.cshtml 页面访问 AspNetUsers 中的数据? - How to access data in AspNetUsers from .cshtml pages in ASP.NET Razor pages? 如何将“查询参数”从 a.razor 页面传递到 ASP.NET 核心 Blazor 中的 .cshtml 页面 - How can I pass 'Query Params' from a .razor page to .cshtml page in ASP.NET Core Blazor 如何在 ASP.NET Core Razor Pages 项目的 _layout.cshtml 文件中使用 Razor 页面使用实体框架作为部分视图? - How to use Razor Page Using Entity Framework as a partial view in _layout.cshtml file in ASP.NET Core Razor Pages project? 如何在 asp.net 核心 .NET6(Razor 页面)中的单个 cshtml 中显示来自多个表/模型的数据 - How to display data from multiple tables/models in a single cshtml in asp.net core .NET6 (Razor pages) Asp.net Core Razor 页面无法从 csHTML 获取值到 C# - Asp.net Core Razor Pages Unable to fetch value from csHTML to C# 如何在 ASP.NET 核心 Razor 页面中重用 _ViewImports.cshtml? - How to reuse _ViewImports.cshtml in ASP.NET Core Razor Pages? asp.net 核心 razor 页面 C# 中的页面文件夹中使用 Partial.cshtml 文件的 CS7036 错误消息 - CS7036 error message using a Partial.cshtml file in a Pages folder in asp.net core razor pages C# 如何将用户在文本框中输入的文本从视图传递到 asp.net 应用程序中的 controller。我在 razor 或 cshtml 中的视图 - how can I pass the text which user entered in the text box from the view to controller in asp.net application.My view in razor or cshtml 如何在自定义构建的 ASP.NET Core Razor Pages 可编辑网格中发布行 ID? - How do I post the row id in a custom built ASP.NET Core Razor Pages editable Grid?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM