Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add and bind a cs file to an ASCX/ASPX page that doesn't alrady have one?

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

like image 607
burnt1ce Avatar asked Sep 10 '09 17:09

burnt1ce


2 Answers

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

<@Page ... Inherits="MyNamespace.MyCustomPage">
like image 132
Jason Avatar answered Oct 16 '22 07:10

Jason


As Jason has already answered, also put a "CodeFile=anycodefile.cs" in the page directive.
<@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.

like image 41
SharePoint Newbie Avatar answered Oct 16 '22 06:10

SharePoint Newbie