Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to create multiple hyperlinks dynamically?

how to create multiple hyperlinks dynamically?

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hemrk
    wrote on last edited by
    #1

    I have button which opens the dialog box to select a filename. the filename with path i am storing in textbox. when i click on the button , i want to create one hyperlink and set its text and navigateurl property to textbox1.text. i can able to create one hyperlink. but i want to create as many hyperlinks as button clicked by the user and textbox is not blank. my code on button click event is Dim HyperLink As HyperLink = Nothing HyperLink = New HyperLink() HyperLink.ID = "HyperLink" & i HyperLink.Text = TextBox1.Text HyperLink.NavigateUrl = "file:///" & TextBox1.Text PlaceHolder1.Controls.Add(HyperLink) PlaceHolder1.Controls.Add(New LiteralControl("
    ")) This is working for one hyperlink , when i click on 2nd time button , the text changes to textbox1.text but it deletes the 1st hyperlink. i tried Me.Controls.Add(New LiteralControl("<a href = " + HyperLink.NavigateUrl + ">" + TextBox1.Text + "</a>")) but its not working. Please help me as i am stuck here since one week. i dont know how to get rid of this problem. i tried with ajaxextension, but i dont know how to use it. one more thing i dont want to upload , i just want to attach this file to email. and if user wants to see this file he can click on hyperlink and he/she can open from the page and they can see the list of files that they have selected for the attachment. Please help...with the code. Thanks in advance. Hemrk.

    C H 2 Replies Last reply
    0
    • H hemrk

      I have button which opens the dialog box to select a filename. the filename with path i am storing in textbox. when i click on the button , i want to create one hyperlink and set its text and navigateurl property to textbox1.text. i can able to create one hyperlink. but i want to create as many hyperlinks as button clicked by the user and textbox is not blank. my code on button click event is Dim HyperLink As HyperLink = Nothing HyperLink = New HyperLink() HyperLink.ID = "HyperLink" & i HyperLink.Text = TextBox1.Text HyperLink.NavigateUrl = "file:///" & TextBox1.Text PlaceHolder1.Controls.Add(HyperLink) PlaceHolder1.Controls.Add(New LiteralControl("
      ")) This is working for one hyperlink , when i click on 2nd time button , the text changes to textbox1.text but it deletes the 1st hyperlink. i tried Me.Controls.Add(New LiteralControl("<a href = " + HyperLink.NavigateUrl + ">" + TextBox1.Text + "</a>")) but its not working. Please help me as i am stuck here since one week. i dont know how to get rid of this problem. i tried with ajaxextension, but i dont know how to use it. one more thing i dont want to upload , i just want to attach this file to email. and if user wants to see this file he can click on hyperlink and he/she can open from the page and they can see the list of files that they have selected for the attachment. Please help...with the code. Thanks in advance. Hemrk.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Does it post back to create the hyperlink ? THe postback is losing the dynamically created control because, well, it doesn't get recreated during te postback. You need to store the details of all the controls you created in viewstate so that on postback you recreate them all. Actually, you can just create links with javascript, if you know the URLs, from the textbox. No postback or AJAX needed.

      Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

      1 Reply Last reply
      0
      • H hemrk

        I have button which opens the dialog box to select a filename. the filename with path i am storing in textbox. when i click on the button , i want to create one hyperlink and set its text and navigateurl property to textbox1.text. i can able to create one hyperlink. but i want to create as many hyperlinks as button clicked by the user and textbox is not blank. my code on button click event is Dim HyperLink As HyperLink = Nothing HyperLink = New HyperLink() HyperLink.ID = "HyperLink" & i HyperLink.Text = TextBox1.Text HyperLink.NavigateUrl = "file:///" & TextBox1.Text PlaceHolder1.Controls.Add(HyperLink) PlaceHolder1.Controls.Add(New LiteralControl("
        ")) This is working for one hyperlink , when i click on 2nd time button , the text changes to textbox1.text but it deletes the 1st hyperlink. i tried Me.Controls.Add(New LiteralControl("<a href = " + HyperLink.NavigateUrl + ">" + TextBox1.Text + "</a>")) but its not working. Please help me as i am stuck here since one week. i dont know how to get rid of this problem. i tried with ajaxextension, but i dont know how to use it. one more thing i dont want to upload , i just want to attach this file to email. and if user wants to see this file he can click on hyperlink and he/she can open from the page and they can see the list of files that they have selected for the attachment. Please help...with the code. Thanks in advance. Hemrk.

        H Offline
        H Offline
        hemrk
        wrote on last edited by
        #3

        I have solved the problem using viewstate. so i didnt use any updatepanel and ajaxtoolkit stuff. it was so simple with viewstate.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups