I'm just starting to do web pages in ASP and all of the code just feels... messy.
<% if (new Random().NextDouble() < 0.5) { %>
<asp:Image ID="image" runat="server" ImageUrl="~/1.jpg" />
<% } else { %>
<asp:Image ID="image" runat="server" ImageUrl="~/2.jpg" />
<% } %>
Currently, I have a very basic page that is light on content, but eventually I am going to have to add logic and more display elements to this. So I come to you, SO.
First, how would I clean up this small segment of code? Second, what do I need to know going forward?
Edit: The asp:Image
tags were generated from VS2008, and then I added the if
blocks based on what I found online. I have plenty of experience with C#, but absolutely none with ASP, so if there's more subtleties about this code that I'm not grasping, by all means enlighten!