Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why would you place asp.net code inside HTML?

Status
Not open for further replies.

romh

Programmer
Jan 3, 2003
297
US
I have a question. Is there an advantage to placing c# code inside the html section of an aspx file instead of in the code section? I am talking about including some c# code with the
<% %>

---------------------------------


Ex:

<% if (x > 3)%>
<a href="xxx.aspx?action=action1"> Click Here To... </a>
<% }
%>
 
Placing code within code tags is generally not a good idea. It still works as that's how classic asp was developed and so it's still supported but not recommended.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
That is what i thought. Thanks for the info. The funny thing is that the page i am looking at has lots of c# code in the code area, but also has these areas where conditional logic was inserted inside the html as shown above. Thanks anyway.

 
It looks like they wanted to add hyperlinks based on some value, instead of adding them dynamically to the page.

Jim
 
But they should have added the hyperlinks dynamically. Right? In order to follow ASP.NET's manner of doing it.
 
Yes, that would be the proper way to do it. What they have done is to include classic ASP coding with .NET coding.
 
It's funny (and sometimes disturbs me) how people can't get away with what they're used to. In my current project, we're supposed to transform a classic-ASP application to .NET framework. To my disappointment I still see most of classic codes disguising as .NET :(
 
I agree. I programmed very briefly with ASP years ago. I don't like the way they mixed the two either.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top