473,508 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using inline stmts vs Page_Load event

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
Nov 17 '05 #1
3 1355
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.

"Jack Frost" <ex****@exc.dom> wrote in message
news:3f**********@newspeer2.tds.net...
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

Nov 17 '05 #2

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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.
Nov 17 '05 #3
> 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/d...displaylang=en

--
HTH,

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

"Jack Frost" <ex****@exc.dom> wrote in message
news:3f**********@newspeer2.tds.net...
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2665
by: Studio P.M. | last post by:
Dear colleagues, I kindly ask the C# developers community to help me to REALLY understand the Page_Load event, so to REALLY have it under control. Reason for this question is that I cannot...
0
950
by: Jessard | last post by:
Hi, Which will be executed first? A Page_Load event in the aspx.vb file or an inline vb.net serverside script in the html? Jesse
6
3410
by: Anders M | last post by:
I'm trying to use Inline-code to call Page_load, Page_Init or Page_PreRender methods. I've also got a code behind c#-file. I can define inline methods for buttons and so on...that works fine....
12
3798
by: John M | last post by:
Hello, On Microsoft Visual Studio .NET 2003, I want to use some global elements, that can be used in each one of my pages. i.e I put a oleDBConnection on global.asax.vb How can I use it...
4
3944
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques...
3
1653
by: Nathan Sokalski | last post by:
I am using the AddHandler statement to add a CheckedChanged event handler to a series of RadioButtons that I create in a loop. However, the handler is not being called for a reason I cannot...
2
1046
by: tshad | last post by:
Is there a way to put inline data in a label? For example, I would normally do something like this to put a name that I have in my session variables in my asp:label: Name.Text =...
1
2951
by: rockdale | last post by:
Hi, I have a masterpage and on the page_load event I Populate my mainmenu from database. I the page_load event of my content, I am trying to programmly select the menuitem that represent...
6
1868
by: tshad | last post by:
I was looking at a page that showed how to set up a custom event and it seems to work ok. But I am not sure how I would use it. How would I subscribe to it. There is actual action (such as...
0
7227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.