Jump to content
Xtreme .Net Talk

position a hyperlink


Recommended Posts

Guest raemdop
Posted

hi,

 

I have some code where I create an array of hyperlinks and put them on a webform. Is there a way to position the Hyperlinks on this webform, because they are all one 1 horizontal line on top of the page.

 

Thanks for reading my problem

Raemdop

 


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       'Put user code to initialize the page here

       Dim sid() As HyperLink

       Dim i As Integer

       For i = 0 To 100

           Dim hl As New HyperLink()
           ReDim sid(i)

           hl.NavigateUrl = "targetPage.aspx"
           hl.Text = "test"

           sid(i) = hl

           'this does not work !!!!!!!!!!!!!!!!

           sid(i).Style.Item("top") = 100 + i

           sid(i).Style.Item("left") = 50

           Me.Controls.Add(sid(i))

       Next i

   End Sub

  • *Experts*
Posted

Because you're only increasing the loop by one, you're only setting it to one pixel above the hyperlink before it (100 + i). I suggest you multiply "i" by something to move the link down on the page more, maybe something like this:

           sid(i).Style.Item("top") = 100 + (i * 20) 

That example will put the hyperlink 20 pixels below the last one. You might have to increase the number you're multiplying by to get them in the right position.

 

HTH

 

And yes Robby, this is VB.NET. (actually ASP.NET, but it's close enough) :)

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...