Language="C#" required in code in front

  • Thread starter Thread starter fred
  • Start date Start date
F

fred

Does anyone know why Language="C#" is required in the code in front of
aspx and ascx files?

for example in the header of my aspx file:

<%@ Control Language="c#" Inherits="Blah.Apps.Controls.Announcement"
CodeFile="Announcement.ascx.cs" %>

if i don't have that in the header, Announcement.ascx.cs in the IDE (VS
2005) will blow up with object does not exist in current context on any
c# code dealing like namespace declarations.

in vs2005 i have tools>options>text editior>file extension set for the
extension .cs - Microsoft Visual C# so shouldn't the aspx.cs and
ascx.cs know to use language C# without explicitly setting it in the
code in front header?

Any info on this is appreciated. Thanks.

- Fred
 
oops MT i meant "for example in the header of my ascx file:" instead of
"for example in the header of my aspx file:"
 
The language=C# bit is referring to any embedded code it may come accross
within the aspx/ascx .. the aspx/ascx is dynamically compiled (at run time
by the asp.net host in IIS) into a class which inherits from your base
class. When this happens your code behind source file is nowhere to be found
(it is already compiled into the .dll)

Cheers,

Greg Young
MVP - C#
 
Back
Top