By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,882 Members | 2,082 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,882 IT Pros & Developers. It's quick & easy.

Use asp:Table in aspx.vb with hyperlinks

P: 38
Expand|Select|Wrap|Line Numbers
  1. Dim I As Integer
  2. Dim needfooter As boolean
  3. Dim Literal1 As New Literal()
  4. Define_List1_Data()
  5.  
  6. Dim html As New StringBuilder() 'Building an HTML string.
  7. html.Append("<table border = '1' cellspacing=\'0\' cellpadding=\'2\' border=\'1\'><tr>")      'Table start.
  8.         For I = 1 to 8
  9.             html.Append("<th>column " & i & "</th>")
  10.         Next
  11.       html.Append("</tr>")       'Building the Data rows.
  12.         for I = 1 to 88
  13.         needFooter = true
  14.         if I mod 8 = 0 then html.Append("<tr>")
  15.     html.Append("<TD align = 'center'>")
  16. **Here is my problem **
  17. I want the cells to be links to a Sub in this page but it won't accept what I typed.
  18.     html.Append("<A HREF='javascript:DisplayConstellations(I)'>" & ConName(I) & "</A>")
  19.     html.Append("</TD>")
  20.         if I mod 8 = 8 Then
  21.             html.Append("</tr>")
  22.             needFooter = false
  23.     End If
  24.      Next
  25.         html.Append("</table>")        'Table end.
  26. PlaceHolder1.Controls.Add(New Literal() With{.Text=html.ToString()})
Any suggestions to allow it to link to the Sub?
Dec 10 '15 #1
Share this Question
Share on Google+
3 Replies


100+
P: 299
Your "DisplayConstellations(I)" is not accepted because your integer is inside of quotes. Try using something like this:

Expand|Select|Wrap|Line Numbers
  1. Html.Append("<A HREF=javascript:DisplayConstellations(" & I & ")>" & ConName(I) & "</A>")
Dec 10 '15 #2

P: 38
That didn't work. I use html.Append("<A HREF='#DisplayConstellations(" & 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.
Dec 10 '15 #3

P: 38
Html.Append("<a href='javascript:DisplayConstellations(" & 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.
Dec 12 '15 #4

Post your reply

Sign in to post your reply or Sign up for a free account.