Positioning hyperlinks dynamicaly (in code)

Discussion in 'ASP .Net' started by carlos.cruz@algeco.pt, Mar 4, 2004.

  1. Guest

    Hi,

    I trying to create dinamicaly hyperlinks, which I manage to do with the
    following code:

    Protected Overrides Sub OnPreRender(ByVal e As EventArgs)

    ctl = New HyperLink
    ctl.Target = "_blank"
    ctl.ID = "hl"
    ctl.Text = "Algeco.pt"
    ctl.NavigateUrl = "http://www.algeco.pt"
    Me.Controls.Add(ctl)

    ctl = New HyperLink
    ctl.Target = "_blank"
    ctl.ID = "h2"
    ctl.Text = "Solbinet.pt"
    ctl.NavigateUrl = "http://www.solbinet.pt"
    Me.Controls.Add(ctl)

    MyBase.OnPreRender(e)
    End Sub

    The question is how can I set the position.

    Thanks in advance

    CC
     
    , Mar 4, 2004
    #1
    1. Advertising

  2. Stanley Guest

    Try putting your links into a span tag:
    Me.Controls.Add(New LiteralControl("<span style=""position:absolute;left:100;top:120;"">")
    Me.Controls.Add(ctl)
    Me.Controls.Add(New LiteralControl("</span>")

    -Stanley
    <> wrote in message news:%...

    Hi,

    I trying to create dinamicaly hyperlinks, which I manage to do with the following code:

    Protected Overrides Sub OnPreRender(ByVal e As EventArgs)

    ctl = New HyperLink
    ctl.Target = "_blank"
    ctl.ID = "hl"
    ctl.Text = "Algeco.pt"
    ctl.NavigateUrl = "http://www.algeco.pt"
    Me.Controls.Add(ctl)

    ctl = New HyperLink
    ctl.Target = "_blank"
    ctl.ID = "h2"
    ctl.Text = "Solbinet.pt"
    ctl.NavigateUrl = "http://www.solbinet.pt"
    Me.Controls.Add(ctl)

    MyBase.OnPreRender(e)
    End Sub

    The question is how can I set the position.

    Thanks in advance

    CC
     
    Stanley, Mar 4, 2004
    #2
    1. Advertising

  3. nfedin Guest

    Put a Placeholder control on your ASPX or ASCX page. Place it where
    you want the hyper links to be displayed. Then add the Hyperlink
    controls to Placeholder.

    Neil

    "Stanley" <> wrote in message news:<>...
    > Try putting your links into a span tag:
    > Me.Controls.Add(New LiteralControl("<span
    > style=""position:absolute;left:100;top:120;"">")
    > Me.Controls.Add(ctl)
    > Me.Controls.Add(New LiteralControl("</span>")
    >
    > -Stanley
    > <> wrote in message
    > news:%...
    >
    > Hi,
    >
    > I trying to create dinamicaly hyperlinks, which I manage to do with
    > the following code:
    >
    > Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
    >
    > ctl = New HyperLink
    > ctl.Target = " blank"
    > ctl.ID = "hl"
    > ctl.Text = "Algeco.pt"
    > ctl.NavigateUrl = "http://www.algeco.pt"
    > Me.Controls.Add(ctl)
    >
    > ctl = New HyperLink
    > ctl.Target = " blank"
    > ctl.ID = "h2"
    > ctl.Text = "Solbinet.pt"
    > ctl.NavigateUrl = "http://www.solbinet.pt"
    > Me.Controls.Add(ctl)
    >
    > MyBase.OnPreRender(e)
    > End Sub
    >
    > The question is how can I set the position.
    >
    > Thanks in advance
    >
    > CC
    > --
     
    nfedin, Mar 4, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bisser Milanov
    Replies:
    2
    Views:
    545
    Bisser Milanov
    Jun 26, 2003
  2. Marc Nederhoff

    Adding style sheet dynamicaly

    Marc Nederhoff, Nov 5, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    439
    charles
    Nov 5, 2003
  3. moondaddy
    Replies:
    7
    Views:
    2,840
    Steven Cheng[MSFT]
    Feb 12, 2004
  4. Carlos Cruz

    Events of a dynamicaly created control

    Carlos Cruz, May 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    321
    Rick Spiewak
    May 2, 2004
  5. leon
    Replies:
    3
    Views:
    509
    Michelle Hlaing
    Nov 30, 2004
Loading...

Share This Page