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. Make url clickable in DIV

Make url clickable in DIV

Scheduled Pinned Locked Moved ASP.NET
help
5 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.
  • S Offline
    S Offline
    sumit7034
    wrote on last edited by
    #1

    hi I am entering some text in div at run time. I want if a website url is entered then it should be clickable and redirect to that site just like in chatting window. Please Help. Thanks in advance.:rose:

    P A 2 Replies Last reply
    0
    • S sumit7034

      hi I am entering some text in div at run time. I want if a website url is entered then it should be clickable and redirect to that site just like in chatting window. Please Help. Thanks in advance.:rose:

      P Offline
      P Offline
      Prosanta Kundu online
      wrote on last edited by
      #2

      Hi Check the text is a valid url with regular expression, if valid then render the text with "textvalue' tag. Cheers Prosanta

      S 1 Reply Last reply
      0
      • P Prosanta Kundu online

        Hi Check the text is a valid url with regular expression, if valid then render the text with "textvalue' tag. Cheers Prosanta

        S Offline
        S Offline
        sumit7034
        wrote on last edited by
        #3

        I am entering text in div on button click at runtime just like chat window when user click on send button the text is entered into div. In that case how to do this?

        H 1 Reply Last reply
        0
        • S sumit7034

          I am entering text in div on button click at runtime just like chat window when user click on send button the text is entered into div. In that case how to do this?

          H Offline
          H Offline
          Haroon Sarwar
          wrote on last edited by
          #4

          you will have to do the same thing that Prosanta already said...search for text that could be links and make them into links. Here is a sample that shows how to do this: http://benalman.com/code/test/js-linkify/[^]

          1 Reply Last reply
          0
          • S sumit7034

            hi I am entering some text in div at run time. I want if a website url is entered then it should be clickable and redirect to that site just like in chatting window. Please Help. Thanks in advance.:rose:

            A Offline
            A Offline
            April Fans
            wrote on last edited by
            #5

            Hi, you can refer to the following code: private void Button1_Click(object sender, System.EventArgs e) { string strContent = InputTextBox.Text;// <---the input text Regex urlregex = new Regex(@"(http:\/\/([\w.]+\/?)\S*)", // <--check if url RegexOptions.IgnoreCase| RegexOptions.Compiled); strContent = urlregex.Replace(strContent, "<a href=\"\" target=\"_blank\"></a>"); // <-- set display like a link Regex emailregex = new Regex(@"([a-zA-Z_0-9.-]+\@[a-zA-Z_0-9.-]+\.\w+)", RegexOptions.IgnoreCase| RegexOptions.Compiled); strContent = emailregex.Replace(strContent, "<a href=mailto:></a>"); lbContent.Text += "<br>"+strContent; }

            April Comm100 - Leading Live Chat Software Provider

            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