471,316 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

@Page Attributes: ClassName vs. Inherits ??

Between ClassName and Inherits, which attribute is set to specify the class
that a page uses? I would think that would be inherits. Further, the
description for ClassName is:

Specifies the class name for the page that will be dynamically compiled
automatically when the page is requested. This value can be any valid class
name but should not include a namespace.

So this is what will decidw what gets compiled? Then what is the point of
the src attribute? Are these two attributes mutially exclusive?
Jul 21 '05 #1
4 6999
You can use ClassName to give a name to the page, when you use inline
code to define the page (using server-side script blocks).

If the server side code for the page is not defined inline, the source
can be specified in 2 ways:
- using the Inherits attribute - the code will be compiled into a DLL
before deployement. The Inherits attribute specifies which class
contains the code-behind for the given page.
- using the Src attribute - the code will be compiled dynamically at
runtime.

Joshua Flanagan
http://flimflan.com/blog

Ben R. wrote:
Between ClassName and Inherits, which attribute is set to specify the class
that a page uses? I would think that would be inherits. Further, the
description for ClassName is:

Specifies the class name for the page that will be dynamically compiled
automatically when the page is requested. This value can be any valid class
name but should not include a namespace.

So this is what will decidw what gets compiled? Then what is the point of
the src attribute? Are these two attributes mutially exclusive?

Jul 21 '05 #2
Hi Joshua,

Thanks for your response. Src and Inherits are much clearer. Could you give
me a scenario where you'd make use of the ClassName attribute? Would it be if
you were making a user control and wanted to be able to import the class it
generated?

-Ben

"Joshua Flanagan" wrote:
You can use ClassName to give a name to the page, when you use inline
code to define the page (using server-side script blocks).

If the server side code for the page is not defined inline, the source
can be specified in 2 ways:
- using the Inherits attribute - the code will be compiled into a DLL
before deployement. The Inherits attribute specifies which class
contains the code-behind for the given page.
- using the Src attribute - the code will be compiled dynamically at
runtime.

Joshua Flanagan
http://flimflan.com/blog

Ben R. wrote:
Between ClassName and Inherits, which attribute is set to specify the class
that a page uses? I would think that would be inherits. Further, the
description for ClassName is:

Specifies the class name for the page that will be dynamically compiled
automatically when the page is requested. This value can be any valid class
name but should not include a namespace.

So this is what will decidw what gets compiled? Then what is the point of
the src attribute? Are these two attributes mutially exclusive?

Jul 21 '05 #3
You use the ClassName whn you use inline code. It works for Pages and
user controls (which use the Control directive instead of Page).

Consider a file called MyPage.aspx that contained:

<%@ Page Language="C#" ClassName="MyClassName" %>
<html>
<body>
Hello <asp:Label id="lblName" runat="server"></asp:Label>
<script runat="server">
void Page_Load(object sender, EventArgs e){
lblName.Text = "Josh";
}
</script>
</body>
</html>
This page is completely self-contained. Notice that there is no
MyPage.aspx.cs file required. All of the HTML and server-side code is
included in the single page. Since there is no C# code file, you are
not explicitly defining a class. In order to give the page's class a
name, you use the ClassName attribute.

Ben R. wrote:
Hi Joshua,

Thanks for your response. Src and Inherits are much clearer. Could you give
me a scenario where you'd make use of the ClassName attribute? Would it be if
you were making a user control and wanted to be able to import the class it
generated?

-Ben

"Joshua Flanagan" wrote:

You can use ClassName to give a name to the page, when you use inline
code to define the page (using server-side script blocks).

If the server side code for the page is not defined inline, the source
can be specified in 2 ways:
- using the Inherits attribute - the code will be compiled into a DLL
before deployement. The Inherits attribute specifies which class
contains the code-behind for the given page.
- using the Src attribute - the code will be compiled dynamically at
runtime.

Joshua Flanagan
http://flimflan.com/blog

Ben R. wrote:
Between ClassName and Inherits, which attribute is set to specify the class
that a page uses? I would think that would be inherits. Further, the
description for ClassName is:

Specifies the class name for the page that will be dynamically compiled
automatically when the page is requested. This value can be any valid class
name but should not include a namespace.

So this is what will decidw what gets compiled? Then what is the point of
the src attribute? Are these two attributes mutially exclusive?

Jul 21 '05 #4
Thanks for the detailed response, Josh...

-Ben

"Joshua Flanagan" wrote:
You use the ClassName whn you use inline code. It works for Pages and
user controls (which use the Control directive instead of Page).

Consider a file called MyPage.aspx that contained:

<%@ Page Language="C#" ClassName="MyClassName" %>
<html>
<body>
Hello <asp:Label id="lblName" runat="server"></asp:Label>
<script runat="server">
void Page_Load(object sender, EventArgs e){
lblName.Text = "Josh";
}
</script>
</body>
</html>
This page is completely self-contained. Notice that there is no
MyPage.aspx.cs file required. All of the HTML and server-side code is
included in the single page. Since there is no C# code file, you are
not explicitly defining a class. In order to give the page's class a
name, you use the ClassName attribute.

Ben R. wrote:
Hi Joshua,

Thanks for your response. Src and Inherits are much clearer. Could you give
me a scenario where you'd make use of the ClassName attribute? Would it be if
you were making a user control and wanted to be able to import the class it
generated?

-Ben

"Joshua Flanagan" wrote:

You can use ClassName to give a name to the page, when you use inline
code to define the page (using server-side script blocks).

If the server side code for the page is not defined inline, the source
can be specified in 2 ways:
- using the Inherits attribute - the code will be compiled into a DLL
before deployement. The Inherits attribute specifies which class
contains the code-behind for the given page.
- using the Src attribute - the code will be compiled dynamically at
runtime.

Joshua Flanagan
http://flimflan.com/blog

Ben R. wrote:

Between ClassName and Inherits, which attribute is set to specify the class
that a page uses? I would think that would be inherits. Further, the
description for ClassName is:

Specifies the class name for the page that will be dynamically compiled
automatically when the page is requested. This value can be any valid class
name but should not include a namespace.

So this is what will decidw what gets compiled? Then what is the point of
the src attribute? Are these two attributes mutially exclusive?

Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by bmgz | last post: by
1 post views Thread by Michael Evanchik | last post: by
3 posts views Thread by | last post: by
1 post views Thread by Arpan | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.