Skip to main content
Home  › ... 2sxc Apps

Data Tutorials

Tutorial Home
#1 Data from the App using App.Data

Basic Example from App.Data

The easiest data to access comes from the current environment - like from the App or from DNN itself. The following example gets Persons data from the App.Data["Persons"] and just loops through them. This is similar to the example in the content tutorial, except that the data comes from the App.Data instead of the current instance Data.

Requirements
Resources
  • Douglas Adams
  • Terry Pratchett
  • Neil Gaiman
  • George Akerlof
  • Raphael Müller (not an author)
  • Ed Hardy
#1 Data from the App using App.Data

Source Code of this file

Below you'll see the source code of the file. Note that we're just showing the main part, and hiding some parts of the file which are not relevant for understanding the essentials. Click to expand the code

@inherits Custom.Hybrid.Razor14
@using ToSic.Razor.Blade;
<!-- unimportant stuff, hidden -->
Basic Example from App.Data The easiest... <!-- unimportant stuff, hidden -->
<ul>
  @foreach (var person in AsList(App.Data["Persons"])) {
    <li @Edit.TagToolbar(Content, settings: new { hover = "left" })>
      @if (Text.Has(person.Mugshot)) {
        <img loading="lazy" src='@Link.Image(person.Mugshot, width: 50, height: 50, resizeMode: "crop")' width="50px" style="border-radius: 50%">
      }
      @person.FirstName  @person.LastName
    </li>
  }
</ul>


<!-- unimportant stuff, hidden -->