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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Text as hyperlink in Text box

Text as hyperlink in Text box

Scheduled Pinned Locked Moved ASP.NET
comhelpquestion
7 Posts 4 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.
  • O Offline
    O Offline
    Orion Buttigieg
    wrote on last edited by
    #1

    hello, i'm trying to figure out a way to get my url's to show up as url hyperlinks when i put them in a text box. something like a word doc when you put in a url it becomes a hyperlink. or such as in hotmail when you switch to rtf mode. i can do it with a label control by setting some tags on either side of say a variable and then set the text as some value. this.label1.Text += "mylink"; this works as far is that it will display the word 'mylink' and when you click, it will take you to what ever url is sitting in the variable after the href. Problem. i can't do multi lines in label controls. however, when setting the above code into a textbox it shows the code as a string as opposed to a hyperlink. so is there a way to get a text box to display these links as hyperlinks ?? am i missing something? thanks, Orion Orion orion.buttigieg@Teamplate.com www.Teamplate.com

    A 1 Reply Last reply
    0
    • O Orion Buttigieg

      hello, i'm trying to figure out a way to get my url's to show up as url hyperlinks when i put them in a text box. something like a word doc when you put in a url it becomes a hyperlink. or such as in hotmail when you switch to rtf mode. i can do it with a label control by setting some tags on either side of say a variable and then set the text as some value. this.label1.Text += "mylink"; this works as far is that it will display the word 'mylink' and when you click, it will take you to what ever url is sitting in the variable after the href. Problem. i can't do multi lines in label controls. however, when setting the above code into a textbox it shows the code as a string as opposed to a hyperlink. so is there a way to get a text box to display these links as hyperlinks ?? am i missing something? thanks, Orion Orion orion.buttigieg@Teamplate.com www.Teamplate.com

      A Offline
      A Offline
      Arjan Einbu
      wrote on last edited by
      #2

      HTML textboxes don't support hyperlinks or any other formatting inside a text.

      O 1 Reply Last reply
      0
      • A Arjan Einbu

        HTML textboxes don't support hyperlinks or any other formatting inside a text.

        O Offline
        O Offline
        Orion Buttigieg
        wrote on last edited by
        #3

        ok fair enough. so in light of what i'm trying to do is there a suggestion from anyone out there on how i'd go about doing this..?? Orion orion.buttigieg@Teamplate.com www.Teamplate.com

        J 1 Reply Last reply
        0
        • O Orion Buttigieg

          ok fair enough. so in light of what i'm trying to do is there a suggestion from anyone out there on how i'd go about doing this..?? Orion orion.buttigieg@Teamplate.com www.Teamplate.com

          J Offline
          J Offline
          J Dunlap
          wrote on last edited by
          #4

          Use a RichTextBox?

          "Blessed are the peacemakers, for they shall be called sons of God." - Jesus
          "You must be the change you wish to see in the world." - Mahatma Gandhi

          T 1 Reply Last reply
          0
          • J J Dunlap

            Use a RichTextBox?

            "Blessed are the peacemakers, for they shall be called sons of God." - Jesus
            "You must be the change you wish to see in the world." - Mahatma Gandhi

            T Offline
            T Offline
            theJazzyBrain
            wrote on last edited by
            #5

            dont use a text box. The only way to do this is to use a DIV tag instead and set the CONTENTEDITABLE attribute of the DIV tag as such: <DIV id=myRichText CONTENTEDITABLE></DIV> This will not only allow you to have links but full HTML editing capabilities. The only problem is that if you want this to be submited to a web form you will need to have a hidden input control and on submit set the value of the hidden control to the innerHTML of the DIV tag. Oh, and this works in IE only not Netscape or Opera:( hope this helps theJazzyBrain Wise is he who asks good questions, not he who gives good answers

            O 1 Reply Last reply
            0
            • T theJazzyBrain

              dont use a text box. The only way to do this is to use a DIV tag instead and set the CONTENTEDITABLE attribute of the DIV tag as such: <DIV id=myRichText CONTENTEDITABLE></DIV> This will not only allow you to have links but full HTML editing capabilities. The only problem is that if you want this to be submited to a web form you will need to have a hidden input control and on submit set the value of the hidden control to the innerHTML of the DIV tag. Oh, and this works in IE only not Netscape or Opera:( hope this helps theJazzyBrain Wise is he who asks good questions, not he who gives good answers

              O Offline
              O Offline
              Orion Buttigieg
              wrote on last edited by
              #6

              thanks for that suggestion. i didn't know i could do that. but these are web forms i'm dealing with, and for reasons i won't get into i'm limited to the type of web controls i can use. a rich text box isn't one of them unfortunately. can i do it in a listcontrol?? thanks, Orion Orion orion.buttigieg@Teamplate.com www.Teamplate.com

              O 1 Reply Last reply
              0
              • O Orion Buttigieg

                thanks for that suggestion. i didn't know i could do that. but these are web forms i'm dealing with, and for reasons i won't get into i'm limited to the type of web controls i can use. a rich text box isn't one of them unfortunately. can i do it in a listcontrol?? thanks, Orion Orion orion.buttigieg@Teamplate.com www.Teamplate.com

                O Offline
                O Offline
                Orion Buttigieg
                wrote on last edited by
                #7

                i must always remind myself to keep things simple. on web forms you can use a listbox. a list box has both a text property and value. i set the url into the value property and set the text to whatever i want. the scroll bar is there. on the selected event i just have to grab the value from the selected item and throw that into a java script line to open that url in a new page. works like a charm and not much extra code. it doesn't show up as a hyper link but that's ok. i can always put a tool tip that tells them to click on an item. thanks for everyone's help and suggestions. :) Orion Orion orion.buttigieg@Teamplate.com www.Teamplate.com

                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