DEV Community

Cover image for CodeBehind 3.8 Released
elanatframework
elanatframework

Posted on

CodeBehind 3.8 Released

CodeBehind is a backend framework based on .NET Core. CodeBehind is published by Elanat and has come to end the monopoly of Microsoft web frameworks on .NET. CodeBehind is a shining diamond in the .NET ecosystem.

The CodeBehind Framework offers several benefits that can significantly increase development efficiency and application performance. With its modular architecture, dynamic compilation capabilities, and improved speed, CodeBehind is a compelling choice for developers looking to modernize their web applications while maintaining a familiar coding environment. As organizations strive for agility and responsiveness in their software solutions, CodeBehind stands out as a robust framework that effectively meets contemporary development needs.

Version 3.8

The first version of CodeBehind was released in 2023 and so far, great features have been added to it. Version 3.8 is the latest version of this framework that was recently released. In this version, the default template has been improved and the feature of adding tags to the top and bottom of the tags is supported in this version.

Improve default template

There is a default template in the CodeBehind framework that you can create in your project.

To add the default template, you need to create a new ASP.NET Core Empty project and add the CodeBehind Framework NuGet package to the project.

In the link below, you can get the latest version of CodeBehind.

https://www.nuget.org/packages/CodeBehind/

Then you need to configure the CodeBehind in the Program.cs class.

The codes below show the configuration of the CodeBehind framework in ASP.NET Core.

var builder = WebApplication.CreateBuilder(args);

var app = builder.Build();

SetCodeBehind.CodeBehindCompiler.Initialization(!app.Environment.IsDevelopment());

app.UseCodeBehind(true);

app.Run();
Enter fullscreen mode Exit fullscreen mode

After completing the above steps correctly, if you run the project for testing, the default CodeBehind template will be created.

The screenshot below is related to the default template version 3.8.

Image description

In versions before 3.8, when the height of the content was low, the footer was added at the end of the content and it did not have a proper shape.

Screenshot of the default CodeBehind template in previous versions 3.8

Image description

Screenshot of the default CodeBehind template in version 3.8

Image description

As you can see in the picture above, the footer is placed at the bottom of the page when the height of the content is low.

In the new template, a new menu has been added on the left side.

Add tag in before or after this tag

In this version, we added two new features to WebForms Core technology. From now on, you can add new tags before and after the tags.
The code below is a View page.

View

@oage
@controller MyController
<html>
<body>
    <h1>My Company<h1>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

The code below is a controller class. After running this controller, a div tag is added before the h1 tag; Also, a b tag is added after the h1 tag.

Controller

using CodeBehind;

public class MyController : CodeBehindController
{
    public void PageLoad(HttpContext context)
    {
        WebForms form = new WebForms();

        form.AddTagBefore("<h1>", "div");
        form.SetText("<div>", "Text1");

        form.AddTagAfter("<h1>", "b");
        form.SetText("<b>", "Text2");

        Write(form.ExportToWebFormsTag());
    }
}
Enter fullscreen mode Exit fullscreen mode

After the View request, the following result is displayed in the client.

Result

<html>
<body>
    <div>Text1</div>
    <h1>My Company<h1>
    <b>Text2</b>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Related links

CodeBehind on GitHub:
https://github.com/elanatframework/Code_behind

Get CodeBehind from NuGet:
https://www.nuget.org/packages/CodeBehind/

CodeBehind page:
https://elanat.net/page_content/code_behind

Top comments (0)