Friday, July 6, 2012

One idea for speeding up and improving ASPX pages

So I've been porting an internal app from ASP to VB.NET / ASPX. Using subs and functions have made the code very modular; I've been able to rewrite it to operate entirely within the realm of Response.Write outputs. One thing I noticed in the code cleanup, was the repeated use of different HTML tags. With that in mind, I created a table of HTML constants: I figure using that in the code should speed up string processing, as well as making things more readable.

Edit: had to do some rejiggering to get Blogger to display this.
'=== HTML constants ===
const BR As String = "<br />"
const TD As String = "<td>"
const eTD As String = "</td>"
const emptyCell As String = "<td>< /td>"
const TR As String = "<tr>"
const eTR As String = "</tr>"
const blueTD As String = "<td bgcolor='#66CCFF'>"
const tab As String = "&emsp;"
Combining with advice from a guide on using Response.Write, the following example may be of use...
Response r
r.Write( TR & TD & "Hello" & eTD)
r.Write( TD & "World" & eTD & eTR)

No comments:

Post a Comment