Git Product home page Git Product logo

Comments (2)

danroth27 avatar danroth27 commented on July 20, 2024 2

Yup, I think we should just add that section back.

from blazor.docs.

guardrex avatar guardrex commented on July 20, 2024

@danroth27 We had it for a bit but cut it temporarily. Here's what we cut ... would this suffice? (If 'yes', where in the topic would you like it to appear?)

Note: I also cut BlazorRocks.cshtml and BlazorRocksBase.cs out of the sample app, but I have the files here, so I can shoot them back into the sample with the section.

Base class inheritance for a "code-behind" experience

Blazor's Razor files (*.cshtml) mix HTML markup and C# processing code in the same file. The @inherits directive can be used to provide Blazor with a "code-behind" experience that separates view markup from processing code.

The Components Sample app shows how a component can inherit a base class, BlazorRocksBase, to provide its properties and methods.

BlazorRocks.cshtml:

[!code-cshtml]

... it shows this ...

@page "/BlazorRocks"
@inherits BlazorRocksBase

<h1>@BlazorRocksText</h1>

BlazorRocksBase.cs:

[!code-csharp]

... it shows this ...

using Microsoft.AspNetCore.Blazor.Components;

public class BlazorRocksBase : BlazorComponent
{
    public string BlazorRocksText { get; set; } = 
        "Blazor rocks the browser!";
}

The base class must derive from BlazorComponent in the Microsoft.AspNetCore.Blazor.Components namespace.

from blazor.docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.