Wednesday, November 15, 2006

Embedded Code in ASP.NET*

Wednesday, November 15, 2006 8:57:29 PM (GMT Standard Time, UTC+00:00)

Lately I was explaining (the little I know about) PHP to someone and I was commenting on how it focuses on embedding code blocks into HTML which are processed server-side and then the .PHP page is sent to the user. For a comparison I mentioned how PHP and ASPX (ASP.NET pages) differs, in that ASPX uses a code behind file or some script code at the top of the page but there's not really any code embedded into the HTML. But it just clicked that this is wrong!

Something clicked today and I browsed to an MSDN site and clarified that code can be embedded into the ASPX page HTML content, similar to PHP and what was done in the ASP days. This site gives a good idea, but one can easily use the "<% %>" to indicate code. So it's like having the benefits of placing code either place ie. embedded (and thus easily viewable relative to your HTML) or neatly tucked away in the code behind file (where I believe 80% of developers put it).

Interestingly, a comment at MSDN stated "Embedded code blocks are supported in ASP.NET Web pages primarily to preserve backward compatibility with older ASP technology." (Ref) Now... to me this is a bit sad as I'd think that keeping it was a good thing because it gives developers the choice and possibly, since this is similar to PHP, you could probably lure some of the PHP following (as I assume is the reason for all these Express tools).

Anyway..., either way, I'm happy its there!

Related posts:
Select a random row in MS SQL...
Regular expressions
VS2005, ASP.NET 2 & DLLs, DLLs..
MS's ASP.NET and.. PHP
2-way databinding cascading drop down lists within a FormView
ApplicationName Property when customising providers

Thursday, November 16, 2006 1:01:28 PM (GMT Standard Time, UTC+00:00)
It's always funny how much we learn by teaching others. Now, enough of this web development rubbish, start doing some shell scripting.
Thursday, November 16, 2006 6:39:28 PM (GMT Standard Time, UTC+00:00)
EW! Disgusting. er.. What's a shell? ;)

Hmm, I'm surprised Ramal didn't blast me for not knowing that though.. *PhEw, think I've dodged a bullet on that one!
Jason Nurse
Saturday, November 18, 2006 5:52:32 PM (GMT Standard Time, UTC+00:00)
Oh, you thought you got away didn't you?

Yeah, it's there... If you look closely, whenever you use the GridView and all those other nice data driven tools, they have to embed some of the data names within the <% %>..

personally i don't use them, i like my tiering approach :).
Sunday, November 19, 2006 8:14:45 PM (GMT Standard Time, UTC+00:00)
*SnAP! :| *Busted! I really really thought I did! lol

ye, i got'cha with the GridView, it works nicely with the Repeater and Datalist, I just got to remember that <%# Container.DataItem.fieldname %> snippet!

Oh right, I forgot, your tiering... I'll get there... soon!
Jason Nurse
Comments are closed.