Use asp:Table in aspx.vb with hyperlinks

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • John Alexander
    New Member
    • Dec 2011
    • 38

    Use asp:Table in aspx.vb with hyperlinks

    Code:
    Dim I As Integer
    Dim needfooter As boolean
    Dim Literal1 As New Literal()
    Define_List1_Data()
    
    Dim html As New StringBuilder() 'Building an HTML string.
    html.Append("<table border = '1' cellspacing=\'0\' cellpadding=\'2\' border=\'1\'><tr>")      'Table start.
            For I = 1 to 8
                html.Append("<th>column " & i & "</th>")
            Next
          html.Append("</tr>")       'Building the Data rows.
            for I = 1 to 88
    		needFooter = true
            if I mod 8 = 0 then html.Append("<tr>")
    	html.Append("<TD align = 'center'>")
    **Here is my problem **
    I want the cells to be links to a Sub in this page but it won't accept what I typed.
    	html.Append("<A HREF='javascript:DisplayConstellations(I)'>" & ConName(I) & "</A>")
    	html.Append("</TD>")
            if I mod 8 = 8 Then
            	html.Append("</tr>")
            	needFooter = false
    	End If
         Next
            html.Append("</table>")        'Table end.
    PlaceHolder1.Controls.Add(New Literal() With{.Text=html.ToString()})
    Any suggestions to allow it to link to the Sub?
    Last edited by Rabbit; Dec 11 '15, 12:18 AM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Luk3r
    Contributor
    • Jan 2014
    • 300

    #2
    Your "DisplayConstel lations(I)" is not accepted because your integer is inside of quotes. Try using something like this:

    Code:
    Html.Append("<A HREF=javascript:DisplayConstellations(" & I & ")>" & ConName(I) & "</A>")
    Last edited by Luk3r; Dec 10 '15, 10:49 PM. Reason: Code tags messed up

    Comment

    • John Alexander
      New Member
      • Dec 2011
      • 38

      #3
      That didn't work. I use html.Append("<A HREF='#DisplayC onstellations(" & I & ")'>" & ConName(I) & "</A>") Notice that single quote marks are needed for javascript as html.Append use double quotes. I see at the bottom of my browser that it displays localhost/program name/page name/#sub to go to when I hover the mouse over the desired cell but it doesn't do anything. If I put in a page name then it would probably go to that page but the sub I want to use is in this page.
      Last edited by zmbd; Dec 12 '15, 09:34 PM.

      Comment

      • John Alexander
        New Member
        • Dec 2011
        • 38

        #4
        Html.Append("<a href='JavaScrip t:DisplayConste llations(" & I & ")';>" & ConName(I) & "</a></TD>") I finally ended up using javascript in aspx page to receive the click. I was trying to get away from javascript and learn asp.net with vb.net. This is only faking it with javascript and not using aspx.

        Comment

        Working...