Are "inheritance" and "class name" required?

I inherited some elses code and wondered if there was any reason why I would need to store both of these files in the directives on the page? I tried to remove the class and it still works. Just wondering.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="YourProgram.ascx.cs" Inherits="program.YourProgram" ClassName="program.YourProgram" %> 
+4
source share
1 answer

If your ascx file does not contain any code, the ClassName attribute ClassName not needed, see http://blogs.msdn.com/b/thirusrinivasan/archive/2008/07/16/classname-vs-inherits.aspx .

However, Inherits and ClassName do different things. ClassName sets the name of the class generated from the ascx file, while Inherit will make the generated class inherit from the class in the code behind: http://msdn.microsoft.com/en-us/library/vstudio/d19c0t4b(v=vs.100 ) .aspx

+2
source

Source: https://habr.com/ru/post/1482420/


All Articles