Make url clickable in DIV
-
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:
Hi Check the text is a valid url with regular expression, if valid then render the text with "textvalue' tag. Cheers Prosanta
-
Hi Check the text is a valid url with regular expression, if valid then render the text with "textvalue' tag. Cheers Prosanta
-
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?
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/[^]
-
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:
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