Welcome aboard! We are happy you are here and wish you good net-raft!
<%@ Page Language="C#" AutoEventWireup="true"%>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
string MyText = "some text https://net-raft.com/Questions/1311/how-to-detect-the-type-of-a-browser-using-c-in-aspnet-/1311 some text";
string Newstring = "";
char[] delimiterChars = { ' ' };
string[] words = MyText.Split(delimiterChars);
foreach (string word in words)
{
bool isValid = Regex.IsMatch(word,@"^(http|ftp|https|www)://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?$");
if(isValid)
{
Uri myUri = new Uri(word);
string Scheme_Host = myUri.GetLeftPart(System.UriPartial.Authority);
String parentDirectory = myUri.AbsolutePath;
string Myurl;
int chars_url = parentDirectory.Length;
if (chars_url > 62) {
string str1 = parentDirectory.Substring(0,22);
string str2 = parentDirectory.Substring(chars_url - 11, 11);
Myurl = Scheme_Host + str1 + "..." + str2;
Newstring = Newstring + " " + "<" + "a href=" + word + " target=_blank>" + Myurl + "<a>";
}
else
{
Newstring = Newstring + " " + "<" + "a href=" + word + " target=_blank>" + word + "<a>";
}
}
else
{
Newstring = Newstring + " " + word;
}
}
lbltxt.InnerHtml = Newstring;
}
</script>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<form id="form1" runat="server">
<div>
<label id="lbltxt" runat="server"></label>
</div>
</form>
</body>
</html>
The most helpful C# solutions
detect ie C#C#
Click to see more ...
5.7K
853
get latitude and longitude from ip address c#C#
Click to see more ...
3.4K
257
get real user country C#C#
Click to see more ...
2.2K
252
Get real client ip address using C# ?C#
Click to see more ...
2.3K
247
check if cookie exists c#C#
Click to see more ...
7.1K
173
get city country region timezone c#C#
Click to see more ...
3.3K
163
How to detect the browser opera using C# in asp.net ?C#
Click to see more ...
2.8K
136
get hostname using C#C#
Click to see more ...
1.6K
127
Get real client latitude and longitude using C# ?C#
Click to see more ...
1.3K
127
how to initialize a connection to mysql database using C# ?C#
Click to see more ...
2.8K
122