Monday, September 15, 2008

Browser detection in ASP

By using Request.ServerVariables("HTTP_USER_AGENT"), we can write a logic to implement this.
Request.ServerVariables("HTTP_USER_AGENT") will result in the following:
For IE:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
For Firefox:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1

Based on above, we can write below logic.
varBrowser= Request.ServerVariables("HTTP_USER_AGENT")
If InStr(varBrowser, "MSIE") > 0 Then
BrowserType = "IE"
Elseif InStr(varBrowser, "Firefox") > 0 Then
BrowserType = "FireFox"
End if

Saturday, September 13, 2008

Recordset GetString() method

The GetString method returns the specified Recordset as a string.
This method can be used to fill HTML tables in ASP files.

You can find the details of the method in the below link:
http://www.w3schools.com/ADO/met_rs_getstring.asp