"Mitch A" <ex****@exc.dom> wrote in
news:3f**********@newspeer2.tds.net:
What are the advantages of using inline C# code in my aspx pages
(with inline I mean directly in the html between <% %>) versus
code behind. It seems messy and inelegant to have code in both
places (IMHO, using inline *and* code-behind is not object
oriented and it generates less readable code). Since code
behind offers syntax highlighting, autocompletion, member info,
parameterinfo etc, is there any reason (design or other) I
couldn't/shouldn't write all code strictly using code-behind.
Mitch,
I can't think of any. I use code-behind as much as possible. I only
use inline <%= %> tags if I need to insert some text at runtime in a
place where ASP.Net tags can't be used (or at least not easily used).
The <HEAD> section of an HTML page is a good example. What few
inline tags I do use I keep very short, and any actual calculations
are done in code-behind:
<HEAD>
<TITLE>
<%= Globals.Instance.GetCompanyName() %>
</TITLE>
<SCRIPT type="text/javascript"
src="../../scripts/clipboard.js">
</SCRIPT>
<%= Globals.Instance.GetCommentHeader() %>
<META name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<%= Globals.Instance.GetMetaTags() %>
<LINK rel="stylesheet" type="text/css" href="../../portal.css">
</HEAD>
Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/