• CodeBehind

    CodeBehind
    CodeBehind is a back-end framework under ASP.NET Core, in which the design pattern is MVC and allows the creation of dynamic aspx files.

    Why use CodeBehind?

    Using CodeBehind allows you to create dynamic applications with plugin support and not experience the default programming limitations of ASP.NET Core.

    CodeBehind is a stable and reliable framework; Elanat is the most powerful .NET system implemented using the CodeBehind framework.

    Projects based on CodeBehind will have a great logic and a modern architecture; CodeBehind supports aspx pages as views. Each view must introduce a Controller class at the top of the page, the model class is also added at the top of the page, but if the user does not want to use the MVC architecture, CodeBehind gives the user the option.

    Unlike the default model of developing web applications in ASP.NET Core, new CodeBehind aspx pages are distributed in the root path of the application; The presence of the aspx physical file in the root path makes the program more structured.

    By using CodeBehind, you can call aspx pages in each part of your codes and display them in different sections.

    Note: Note that after running the program and compiling the aspx pages by CodeBehind, your program will no longer refer to any of the aspx files.


    Web Parts in CodeBehind

    How to add web part?

    First, copy your compiled project files to the desired path in wwwroot; then copy the main dll file to wwwroot/bin path. You can do the copy while the process is running in the method and then call the code below to compile without restarting the program.


    Getting started with CodeBehind


    View File: Default.aspx
    Model File: Default.aspx.Model.cs
    Controler File: Default.aspx.Controller.cs
    Program File: Program.cs

    You can use the Write method in the model and controller classes; the Write method adds a string value to the ResponseText attribute; you can also change the values of the ResponseText attribute by accessing them directly.

    In the controller class, there is an attribute named IgnoreViewAndModel attribute, and if you activate the IgnoreViewAndModel attribute, it will ignore the values of model and view and you will only see a blank page; this feature allows you to display the values you need to the user and avoid multiple redirects and transfers.

    Note: If you have set the name of a model in the aspx file, You must make sure to call View(ModelName) in the controller class at the end of the method or set the value of IgnoreViewAndModel to true.


    To receive the information sent through the form, you can follow the instructions below:

    The following example shows the power of CodeBehind:


    aspx page
    Controller class

    Each of the pages left.aspx, right.aspx and main.aspx can also call several other aspx files; these calls can definitely be dynamic and an add-on can be executed that the kernel programmers don't even know about.

    Enjoy CodeBehind, but be careful not to loop the program! (Don't call pages that call the current page)


    CodeBehind in NuGet:
    https://www.nuget.org/packages/CodeBehind
    CodeBehind repository in GitHub:
    https://github.com/elanatframework/Code_behind