Create code behind file after aspx has been created

前端 未结 5 512
有刺的猬
有刺的猬 2021-02-01 16:57

I just inherited a web site that was created by a designer. The site was originally created with all *.html files. The designer renamed all the *.html files to *.aspx files.

5条回答
  •  说谎
    说谎 (楼主)
    2021-02-01 17:45

    Based on what I found here: http://forums.asp.net/t/1229894.aspx/1

    1. Right click on your solution explorer.
    2. Add New Item -> Class File.
    3. Name the file as the name of your aspx eg: Default.aspx.cs
    4. When it asks you the file should be in app_code click "no".
    5. In your aspx in page attribute add

      AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default"
      
    6. Similarly in your class file that you just added remove everything. Your class should look like this:

      //all namespaces go here
      
      
      public partial class Default : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
          }
      }
      

提交回复
热议问题