Critical Developers

Programmers Knowledge Base

Client detection from server side

Client detection from server side

string client_ip = System.Web.HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"];
string client_os = Request.Browser.Platform.ToString();
string os_ver = System.Environment.OSVersion.ToString();
string client_browser = Request.Browser.Browser.ToString() + " " + Request.Browser.Version.ToString();

Trim Text in TextBox, Label, Literal etc.,

Make a common function by name "Trimmer". Let it accept yours Label Text or any string and it will give you trimmed text :-
eg. After 25 characters it should print "..."
 
Public Function Trimmer(ByVal trimtext As String)
 If trimtext.Length > 25 Then
     trimtext = Convert.ToString(trimtext).Substring(0, Math.Min(25, Convert.ToString(trimtext).Length)) & "..."
     Else
            trimtext = Convert.ToString(trimtext)
     End If
        Return trimtext
End Function