Make an ASP.NET Application Using Notepad

I made an ASP.NET application using Notepad ++. For this exercise, I do not want to use Visual Studio or any other tool. I want to understand this process.

I created my site and it works fine and everything works fine.

Now I want to add C # code per page, both for the main page and for individual pages.

So far, I have a file called Home.aspx , and I want to add a C # file to it.

I've created a file named Home.aspx.cs . The following is the full contents of the file:

protected void Page_Load(object sender, EventArgs e)
{
    Response.Write("LOAD");
    Response.End();
}

But when the page loads, this file does not load. Obviously, I'm missing something, but I'm not sure what. Perhaps a link in my web.config or some other folder or language link to tell the page that it is C #, or something to report a Page_Load error?

In addition, I want to do the same for my main page, which is currently called masterPage.master .

So, I would make a file called masterPage.master.cs , or is it a completely different way, or can this even be done?

All references to this problem explain how to do this in Visual Studio, which I do not want to use.

+4
source share
4 answers

ASP.NET WebForms .cs .

Home.aspx

<%@ Page Src="Home.aspx.cs" Inherits="HomePage" AutoEventWireup="True" %>

, @Page Directive Src CodeBehind.

( Src CodeFile partial.)

Home.aspx.cs

using System;
using System.Web.UI;

public class HomePage : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write("LOAD");
        Response.End();
    }
}

MasterPage.master

<%@ Master Src="masterPage.master.cs" Inherits="MasterPage" AutoEventWireup="True" %>

, , @Master @Page.

( Src CodeFile partial.)

masterPage.master.cs

public class MasterPage : System.Web.UI.MasterPage
{
}

( code-behind MasterPage , ASP.NET MasterPage, .)

+4

CodeFile :

<%@ Page Language="C#" MasterPageFile="~/MasterPage/MasterPage.master" CodeFile="Home.aspx.cs" Inherits="Home" Title="Content Page"%>

inhereits , .

,

+1

All Articles