如何将一个cs文件添加并绑定到一个没有aldy的ASCX / ASPX页面?

时间:2021-10-23 15:09:41

I know silly question but i tried looking it up on Google with no luck.

我知道愚蠢的问题,但我试着在谷歌上查找它没有运气。

2 个解决方案

#1


5  

Add an Inherits attribute to your <@Page directive with the name of the class represented in the cs file. For example:

使用cs文件中表示的类的名称将 属性添加到

<@Page ... Inherits="MyNamespace.MyCustomPage">

#2


2  

As Jason has already answered, also put a "CodeFile=anycodefile.cs" in the page directive.
<@Page ... Inherits="MyNamespace.MyCustomPage" CodeFile="MyCustomPage.cs">

正如杰森已经回答的那样,在页面指令中也加入了“CodeFile = anycodefile.cs”。 <@Page ... Inherits =“MyNamespace.MyCustomPage”CodeFile =“MyCustomPage.cs”>

If your page has a code-behind file, use the CodeFile attribute. Otherwise put the assembly containing the code behind class in the bin folder and use the inherits. The class must derive from webpage or usercontrol and must be public.

如果您的页面有代码隐藏文件,请使用CodeFile属性。否则将包含代码的程序集放在bin文件夹中并使用继承。该类必须来自网页或用户控件,并且必须是公开的。

#1


5  

Add an Inherits attribute to your <@Page directive with the name of the class represented in the cs file. For example:

使用cs文件中表示的类的名称将 属性添加到

<@Page ... Inherits="MyNamespace.MyCustomPage">

#2


2  

As Jason has already answered, also put a "CodeFile=anycodefile.cs" in the page directive.
<@Page ... Inherits="MyNamespace.MyCustomPage" CodeFile="MyCustomPage.cs">

正如杰森已经回答的那样,在页面指令中也加入了“CodeFile = anycodefile.cs”。 <@Page ... Inherits =“MyNamespace.MyCustomPage”CodeFile =“MyCustomPage.cs”>

If your page has a code-behind file, use the CodeFile attribute. Otherwise put the assembly containing the code behind class in the bin folder and use the inherits. The class must derive from webpage or usercontrol and must be public.

如果您的页面有代码隐藏文件,请使用CodeFile属性。否则将包含代码的程序集放在bin文件夹中并使用继承。该类必须来自网页或用户控件,并且必须是公开的。