blah blah blah is here! blah blah » Close

up0down
link

When writing behind code in a web application if i reference with
<%@ Page Language="C#" Src="Default.aspx.cs" Inherits="WebApp.Default" %>
it works fine. But when i use C# builder or VS.Net it automatically references behind code like
<%@ Page Language="C#" BehindCode="Default.aspx.cs" Inherits="Wendell.Default" %>
which results in an error, so i change them manually.
Is there something i am doing wrong?

last answered 2 years ago

1 answers

up0down
link

Bazza,
I don't know if this info will help, but here goes.
When you specifiy the Src and Inherits tag the the code behind file is not actually compiled until the page is hit for the first time. This is known as Code behind without precompilation.
If you specify JUST the Inherits tag and no Src tag the file will be precompiled (if you're using VS).
"BehindCode" is not the right attribute to use, try Codebehind.
This is what one of mine looks like:
<code>
<%@ Page language="c#" Codebehind="Fund.aspx.cs" AutoEventWireup="false" Inherits="FundsAcct.Fund" %>
</code>
Here is what all that means: The Codebehind attribute is totally ignored by ASP.NET and only used by visual studio so it knows which file to bring up when I do a view code. The AutoEventWireup is true by default, but since visual studio auto generates base event handlers it also sets autoeventwireup to false. the Inherits attribute identifies the class that is the code behind object for this page. Notice, there is no Src.
Hope this helps.
-Jason

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback