using inline stmts vs Page_Load event

  • Thread starter Thread starter Jack Frost
  • Start date Start date
J

Jack Frost

What is the consensus on putting ASP.NET code inline in the html doc versus
using code behind and C#. I find it confusing when pages include code in
both places. For example, using DataBinder.Eval statements in the HTML. Is
there an advantage to doing any coding within the HTML page? It seems
cleaner to do all coding in the webform but I am an admitted DOTNET newbie

Thanks
 
As long as it is not INSIDE the HTML (IOW, it is above the first <html>
tag), it is fine to put your CodeBehind class definition in the same file as
the Page Template. Mixing Code and Content is never a good idea.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
Kevin Spencer said:
As long as it is not INSIDE the HTML (IOW, it is above the first <html>
tag), it is fine to put your CodeBehind class definition in the same file as
the Page Template. Mixing Code and Content is never a good idea.
I agree but many of the MS code samples (IBuySpy for one) employ this
technique. If I can't look to MS for guidance on best practices, where can
I look? Do you have book recommendations?

Thanks again.
 
I agree but many of the MS code samples (IBuySpy for one) employ this
technique.

Not sure what "this technique" refers to.
If I can't look to MS for guidance on best practices, where can
I look? Do you have book recommendations?

You certainly CAN look to MS for guidance on best practices. The .Net SDK,
which is the only "book" I recommend, has a good number of articles on best
practices. You can download the .Net SDK for free from the following URL:

http://www.microsoft.com/downloads/...A6-3647-4070-9F41-A333C6B9181D&displaylang=en

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
Back
Top