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 ... 4.6K 853