Yeah, that would work well. However, IMO, you're not really using .NET the way it's supposed to be used. Using Response.Write is "classic" ASP and will get you into troubles in .NET. This is because you cannot really control the location of the output of Response.Write. If you add code like that in Page_Load it will end up somewhere at the top of your page.
In .NET, it makes much more sense to use a databound control, like a DataList. You can bind this list to a datasource, like an array of HyperLink objects. The following example shows you what I mean:
<%@ Page Language="VB" %>
Sub Page_Load(Sender As Object, E As EventArgs)
Dim HyperLinks(1) As HyperLink
HyperLinks(0) = New HyperLink
HyperLinks(0).Text = "The Disney Site"
HyperLinks(0).NavigateUrl = "http://www.disney.com"
HyperLinks(1) = New HyperLink
HyperLinks(1).Text = "Yahoo"
HyperLinks(1).NavigateUrl = "http://www.yahoo.com"
lstTest.DataSource = HyperLinks
<asp:datalist id="lstTest" runat="server">
navigateurl='<%# DataBinder.Eval(Container.DataItem, "NavigateUrl")%>'
<%# DataBinder.Eval(Container.DataItem, "Text")%>
I prefer this kind of stuff over using Response.Write. This way of coding has a few benefits:
1. Clear separation of UI and code. You can change the layout of the page without affecting the code.
2. It's easy to modify the code; it's clean, simple and not mixed with markup
3. Additions are easily made. Want the Disney tag to open in a new Window? Just add this line:
HyperLinks(0).Target = "_blank"
It may take some time to get used to this kind of programming syntax, and the databinding syntax may look difficult and odd at first, but I am sure in the end it will improve the quality of the applications you can write.
Just my 2 cents....
Everyone is unique, except for me.
While typing this post, I was listening to: Bombtrack
by Rage Against The Machine
(Track 1 from the album: Rage Against The Machine
) What's This?