Tag Archive for browser

Important Browser Reset style rules…

/* reset browser styles */
 
html, body, div, span, 
applet, object, iframe, 
h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, 
img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, 
fieldset, form, label, legend, 
table, caption, tbody, tfoot, thead, tr, th, td {
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    font-size: 12px;
    vertical-align: baseline;
    background: transparent;
}

a, img {
	border:0;
	outline:none;
	text-decoration:none;
}

ol, ul {
    list-style: none;
}

blockquote, q {
    quotes: none;
}

:focus {
    outline: 0;
}

ins {
    text-decoration: none;
}

del {
    text-decoration: line-through;
}

/* tables still need 'cellspacing="0"' in the markup */ 
table {
    border-collapse: collapse;
    border-spacing: 0;
}

source

Php Feedback Form w/ Session and Browser Info

<? include("browser_class.php"); ?> //include class from here <a href="http://snipplr.com/view/35627/php-browser-detection-class/" >http://snipplr.com/view/35627/php-browser-detection-class/</a>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">" >http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></a>
<html xmlns="<a href="http://www.w3.org/1999/xhtml">" >http://www.w3.org/1999/xhtml"></a>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="attSearch.css" type="text/css" />
<style>
body {width:400px;margin:0px auto;text-align:left!important}
h2 {color:green;}
</style>
</head>

<body style="background:none!important;">
<?php
// declare values
$loc = $_COOKIE['location'];
$contact_email = $_POST['EmailAddress'];
$contact_subject = $_POST['Subject'];
$contact_name = $_POST['FullName'];
$contact_message = $_POST['Message'];
$contact_custname = $_SESSION['businessName'];
$contact_accno = $_SESSION['accountNo'];
$mydate = date ( 'l, F d Y g:i A',time()+240 );
// where to send e-mail to
$to = '<a href="mailto:youremail@yourprovider.com">youremail@yourprovider.com</a>';

// e-mail subject
$subject = "Feedback from $contact_custname";

// e-mail message
$message = "You have received feedback:
"."----------------------------------------------
"
."Contact Name: $contact_name
"
."Business Name: $contact_accno, $contact_custname
"
."Subject: $contact_subject
"
."Submitted: $mydate
"
."From IP: {$_SERVER['REMOTE_ADDR']}
"
."URL: $loc
"
."Browser: $Browser->Name $Browser->Version
"
."Message: $contact_message";

$headers = "From: $contact_name <$contact_email>
"
."Reply-To: $contact_email
"
."X-Mailer: PHP/".phpversion();

// check for validation, then send the e-mail
if(empty($contact_name) || empty($contact_email) || empty($contact_subject) || empty($contact_message)) {
echo '<h2>Have feedback?</h2>
<form method="post" action="">
<table id="Form-Details">
<tbody>
<tr><td width="20%">Your Name:</td><td><input type="text" name="FullName" size="40" /></td></tr>
<tr><td width="20%">Subject:</td><td><select name="Subject">
		<option value="Feedback">Feedback</option>
		<option value="Suggestion">Suggestion</option>
		<option value="Bug Report">Bug Report</option>
		<option value="Question">Question</option>
		</select>
</td></tr>
<tr><td width="20%">Email:</td><td colspan="3"><input type="text" name="EmailAddress" size="40" /></td></tr>
<tr><td colspan="4">Message:</td></tr>
<tr><td colspan="4"><textarea rows="6" name="Message" cols="47" class="input"></textarea></td></tr>
<tr><td colspan="4" align="right"><input type="submit" value="Submit Feedback" /></td></tr>
</tbody>
</table>
</form>';
} elseif(!ereg("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $contact_email)) {
echo "<h2 style='font-weight:bold;color:red;'>ERROR: Please enter a valid e-mail address.</h2>";
} else {
mail( $to, $subject, $message, $headers );
echo "<h2>Message Sent!</h2><br /><p>$contact_name,<br /><br />Thank you for your feedback, we will get back to you as soon as possible using $contact_email.";
}
?>
</body>
</html>

source

Click wheel fix for mac (safari + firefox)

// *** inside javascript **
function handleWheel(event) {
	var app = document.getElementById('flashSite');
	var delta = 0;
	if (!event) event = window.event;
	if (event.wheelDelta) {
		delta = -(event.wheelDelta/60); 
	} else if (event.detail) {
		delta = event.detail;
	}
	var o = {
		x: event.screenX,
		y: event.screenY,
		delta: delta,
		ctrlKey: event.ctrlKey,
		altKey: event.altKey,
		shiftKey: event.shiftKey
	};
	if (app && typeof(app.handleWheel) == 'function')
		app.handleWheel(o);
}

// on page onload
if(!(document.attachEvent)) {
	window.addEventListener("DOMMouseScroll", handleWheel, false);
	window.addEventListener('mousewheel', handleWheel, false);
	document.addEventListener('mousewheel', handleWheel, false);
}

// *** inside flash ***
if(ExternalInterface.available){
	ExternalInterface.addCallback("handleWheel", handleWheel);
}

// method that will be accessed from dispatched javascript events
public function handleWheel(event:Object): void {
	var mEvent:MouseEvent = new MouseEvent(MouseEvent.MOUSE_WHEEL, true, false,
		event.x, event.y, this,
		event.ctrlKey, event.altKey, event.shiftKey,
		false, -Number(event.delta));
	this.dispatchEvent(mEvent); // where "this" is the documentClass. Can be "stage" too
}

source

PHP Browser Detect

function getBrowser(){
       $return = array("navigator"=>"", "platform"=>"pc", "version"=>"", "long_version");
       $browsers = "mozilla msie gecko firefox konqueror safari chrome netscape opera mosaic lynx camino amaya omniweb";
       $browsers = split(" ", $browsers);
       $nua = strToLower($_SERVER['HTTP_USER_AGENT']);

       $l = strlen($nua);
       for ($i=0; $i<count($browsers); $i++){
           $browser = $browsers[$i];
           $n = stristr($nua, $browser);
           if(strlen($n)>0){
               $return["long_version"] = "";
               $return["navigator"] = $browser;
               $j=strpos($nua, $return["navigator"])+$n+strlen($return["navigator"])+1;
               if($return['navigator'] == "safari"){
                   $begining = strpos($nua,"version/")+8;
                   $end = stripos($nua,'safari')-$begining;
                   $return['long_version'] = trim(substr($nua,$begining,$end));
                   $temp = explode(".",$return['long_version']);
                   $return['version'] = $temp[0];
               } else {
                   for (; $j<=$l; $j++){
                       $s = substr ($nua, $j, 1);
                       if(is_numeric($return["long_version"].$s) ) {
                           $return["long_version"] .= $s;
                           $temp = explode(".",$return['long_version']);
                           $return['version'] = $temp[0];
                       } else { break; }
                   }
               }
           }
       }

       if (strpos($nua,"mac") !== false) $return["platform"] = "mac";
       if(strpos($return['long_version'],"/") !== false){
           $return['long_version'] = array_shift(explode("/",$return['long_version']));
       }
       return $return;
}

source

Detect IE8

var isIE8 = function() {
    return !!( (/msie 8./i).test(navigator.appVersion) && !(/opera/i).test(navigator.userAgent) && window.ActiveXObject && XDomainRequest && !window.msPerformance );
});

source

Asynchronous ASP.Net Pages, AJAX Helper, WebRequest Passthrough

Main Class (AsyncCall.cs), place in App_Code directory or compile as a dll and place in the bin dirctory of the site:
-------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Net;
using System.Threading;
using System.IO;
using System.Collections.Specialized;

namespace AsyncStuff
{
	public static class AsyncCall
	{
		public sealed class AsyncState
		{
			internal const string QVARNAME = "ASYNCSession";

			public readonly Page CallingPage;
			internal readonly Uri Url;
			private HttpWebRequest _request;
			private HttpWebResponse _response;
			internal readonly SpecificFunction SpecificFunction;
			public readonly object[] Parameters;
			private string _text;
			internal byte[] FormContent;

			//cascaded constructor only (private)
			private AsyncState(Page page)
			{
				this.CallingPage = page;
				this.Url = GetAsyncUrl(page.Request.Url);
			}

			//off-page url
			internal AsyncState(Uri url, Page page, SpecificFunction specificFunction)
			{
				this.CallingPage = page;
				this.Url = GetAsyncUrl(url);
				this.SpecificFunction = specificFunction;
			}

			internal AsyncState(Page page, SpecificFunction specificFunction)
				: this(page)
			{
				this.SpecificFunction = specificFunction;
			}

			internal AsyncState(Page page, SpecificFunction specificFunction, params object[] parameters)
				: this(page, specificFunction)
			{
				this.Parameters = parameters;
			}

			private Uri GetAsyncUrl(Uri uri)
			{
				string url = uri.OriginalString;
				int start = url.IndexOf("?");
				if (start < 0)
				{
					start = url.Length;
					url = url.Insert(start++, "?");
				}
				else
				{
					start++;
					url = url.Insert(start, "&");
				}

				//timestamped query variable inserted to indicate that a page is running asychronously
				url = url.Insert(start, QVARNAME + "=" + DateTime.Now.ToString("MMddyyyyHHmmssffff"));
				return new Uri(url);
			}

			public HttpWebRequest Request
			{
				get { return this._request; }
				internal set { this._request = value; }
			}

			public HttpWebResponse Response
			{
				get { return this._response; }
				internal set { this._response = value; }
			}

			public string GetResponseText()
			{
				if (this._text == null)
				{
					this._text = "";
					if (this._response != null)
						this._text = (new StreamReader(this._response.GetResponseStream())).ReadToEnd();
				}
				if (this._text == "")
					return null;

				return this._text;
			}
		}

		/// <summary>
		/// A delegate function used to create a callback for the RunPageAsynchronously() function
		/// </summary>
		/// <param name="state">The state object that will be returned from the results of the asychronous call</param>
		public delegate void SpecificFunction(AsyncState state);

		/// <summary>
		/// Run an off-page url request as an asychronous request. (Note: this is a seperate session, so don't expect session variables to persist)
		/// </summary>
		/// <param name="url">Off-page URL which contents will be retreived asychronously</param>
		/// <param name="callingPage">The current System.Web.UI.Page object which is making the asychronous call (must implement IHttpAsyncHandler or use the [%@ Page Async="true"] directive)</param>
		/// <returns>true, if the page was able to run asynchronously (a value of false may indicate the %@ Page directive is not using Async="true"</returns>
		public static bool RunAsynchronously(string url, Page callingPage)
		{
			if (callingPage is IHttpAsyncHandler)
			{
				Uri absUrl = new Uri(url, UriKind.RelativeOrAbsolute);
				if (!absUrl.IsAbsoluteUri || absUrl.OriginalString.StartsWith("file"))
				{
					string resolve = callingPage.ResolveUrl(url);
					Uri pageUrl = callingPage.Request.Url;
					string newPath = pageUrl.OriginalString.Replace(pageUrl.PathAndQuery, resolve);
					absUrl = new Uri(newPath, UriKind.Absolute);

					string filePath = callingPage.MapPath(absUrl.AbsolutePath);
					FileInfo fi = new FileInfo(filePath);
					if (!fi.Exists)
						throw new Exception("File Not Found, requestsed relative path does not exist. Check the filename for spelling errors.");
				}
				AsyncState state = new AsyncState(absUrl, callingPage, new SpecificFunction(AfterOffPage));
				callingPage.AddOnPreRenderCompleteAsync(new BeginEventHandler(BeginAsyncOperation), new EndEventHandler(EndAsyncOperation), state);
				return true;
			}
			return false;
		}

		private static void AfterOffPage(AsyncState state)
		{
			if (state==null || state.Response == null || state.CallingPage==null || state.CallingPage.Response==null)
				return;

			//content rewrite (make calling page same as the page called)
			//requires IIS content rewrite pipline mode, so if exception then ignore
			try
			{
				state.CallingPage.Response.Headers.Clear();
				state.CallingPage.Response.Headers.Add(state.Response.Headers);
			}
			catch { }
			state.CallingPage.Response.ContentType = state.Response.ContentType;
			BinaryReader br = new BinaryReader(state.Response.GetResponseStream());
			int len = (int)state.Response.ContentLength;
			byte[] data = br.ReadBytes(len);
			state.CallingPage.Response.OutputStream.Write(data, 0, len);			
		
			state.CallingPage.Response.End();
		}

		/// <summary>
		/// Run the current page request as an asychronous request. (Note: this is a seperate session, so don't expect session variables to persist)
		/// </summary>
		/// <param name="callingPage">The current System.Web.UI.Page object to be processed (must implement IHttpAsyncHandler or use the [%@ Page Async="true"] directive)</param>
		/// <param name="specificFunction">A parameterless function to call on the async request page</param>
		/// <returns>true, if the page was able to run asynchronously (a value of false may indicate the %@ Page directive is not using Async="true"</returns>
		public static bool RunAsynchronously(Page callingPage, SpecificFunction specificFunction)
		{
			if ((callingPage is IHttpAsyncHandler) && !IsRunningAsync(callingPage))
			{
				AsyncState state = new AsyncState(callingPage, specificFunction);
				callingPage.AddOnPreRenderCompleteAsync(new BeginEventHandler(BeginAsyncOperation), new EndEventHandler(EndAsyncOperation), state);
				return true;
			}
			return false;
		}

		/// <summary>
		/// Run the current page request as an asychronous request. (Note: this is a seperate session, so don't expect session variables to persist)
		/// </summary>
		/// <param name="callingPage">The current System.Web.UI.Page object to be processed (must implement IHttpAsyncHandler or use the [%@ Page Async="true"] directive)</param>
		/// <param name="specificFunction">A function to call on the async request page</param>
		/// <param name="parameters">The parameters to pass to the specific function</param>
		/// <returns>true, if the page was able to run asynchronously (a value of false may indicate the %@ Page directive is not using Async="true"</returns>
		public static bool RunAsynchronously(Page callingPage, SpecificFunction specificFunction, params object[] parameters)
		{
			if ((callingPage is IHttpAsyncHandler) && !IsRunningAsync(callingPage))
			{
				AsyncState state = new AsyncState(callingPage, specificFunction, parameters);
				callingPage.AddOnPreRenderCompleteAsync(new BeginEventHandler(BeginAsyncOperation), new EndEventHandler(EndAsyncOperation), state);
				return true;
			}
			return false;
		}

		/// <summary>
		/// Tests to see if the page is in is asynchronous cycle of an asynchronous request made from the RunPageAsynchronously function
		/// </summary>
		/// <param name="page">The page to check for sychronicity</param>
		/// <returns>true if in the asychronous cycle</returns>
		public static bool IsRunningAsync(Page page)
		{
			return (page.Request.QueryString[AsyncState.QVARNAME] != null);
		}

		private static IAsyncResult BeginAsyncOperation(object sender, EventArgs e, AsyncCallback cb, object stateObj)
		{
			if (stateObj is AsyncState)
			{
				AsyncState state = (AsyncState)stateObj;
				state.Request = (HttpWebRequest)HttpWebRequest.Create(state.Url);
				
				//copy relevant header information
				state.Request.Accept = GetTextList<string>(state.CallingPage.Request.AcceptTypes, ", ", true);
				state.Request.AllowAutoRedirect = true;
				state.Request.AllowWriteStreamBuffering = true;
				state.Request.ContentType = state.CallingPage.Request.ContentType + "; " + state.CallingPage.Request.ContentEncoding.WebName;
				state.Request.Method = state.CallingPage.Request.RequestType;
				state.Request.Referer = state.CallingPage.Request.UrlReferrer.OriginalString;
				
				//copy cookies
				if (state.CallingPage.Request.Cookies.Count > 0)
				{
					state.Request.CookieContainer = new CookieContainer();
					List<string> excludedCookies = new List<string> { "ASP.NET_SessionId" };
					foreach (string key in state.CallingPage.Request.Cookies.Keys)
					{
						if (!excludedCookies.Contains(key, StringComparer.CurrentCultureIgnoreCase))
						{
							HttpCookie cookie = state.CallingPage.Request.Cookies[key];
							Cookie copy = new Cookie(cookie.Name, cookie.Value, state.Url.AbsolutePath, state.Url.Host);
							state.Request.CookieContainer.Add(copy);
						}
					}
				}
				
				//copy form variables
				if (state.CallingPage.Request.Form.Count > 0 && state.Request.Method.Equals("POST", StringComparison.CurrentCultureIgnoreCase))
				{
					string pairs = GetTextDictionary(state.CallingPage.Request.Form, "=", "&", true);					
					state.FormContent = state.CallingPage.Request.ContentEncoding.GetBytes(pairs);
					state.Request.ContentLength = state.FormContent.Length;
					state.Request.BeginGetRequestStream(EndRequestStreamCallback, state);
				}

				return state.Request.BeginGetResponse(cb, stateObj);
			}
			return null;
		}

		private static void EndRequestStreamCallback(IAsyncResult ar)
		{
			if (ar.AsyncState is AsyncState)
			{
				AsyncState state = (AsyncState)ar.AsyncState;				
				BinaryWriter sw = new BinaryWriter(state.Request.EndGetRequestStream(ar));
				sw.Write(state.FormContent, 0, state.FormContent.Length);
				sw.Close();
			}
		}

		private static void EndAsyncOperation(IAsyncResult ar)
		{
			if (ar.AsyncState is AsyncState)
			{
				AsyncState state = (AsyncState)ar.AsyncState;
				if (state.Request != null)
				{
					try { state.Response = (HttpWebResponse)state.Request.EndGetResponse(ar); }
					catch (Exception ex) { throw new Exception("WebRequest Error. Remember that asynchronous calls are made from the server and not the client, so any routing done on the client (say...to a testing server) will not be in effect with this request.", ex); };

					if (state.SpecificFunction != null)
					{
						object target = state.SpecificFunction.Target;
						if (target == null)
							target = state.CallingPage;
						try { state.SpecificFunction.Method.Invoke(target, new object[] { state }); }
						catch (Exception ex) { throw new Exception("An error occured in the SpecificFunction supplied, the debug thread is not attached to the function invoked, therefore further debug information is unavailable.", ex); }
					}
				}
			}
		}

		private static string GetTextList<I>(IEnumerable<I> list, string separator, bool urlEncode)
		{			
			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			int index = 0;
			foreach (I item in list)
			{
				if (index > 0)
					sb.Append(separator);				
				if (urlEncode)				
					sb.Append(HttpUtility.UrlPathEncode(item.ToString()));
				else
					sb.Append(item.ToString());
				index++;
			}
			string ret = sb.ToString();
			sb.Length = 0; //destroy memory
			return ret;
		}

		private static string GetTextDictionary<K, V>(IDictionary<K, V> dictionary, string equality, string separator, bool urlEncode)
		{
			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			int index = 0;
			foreach (K key in dictionary.Keys)
			{
				V value = dictionary[key];
				if (index > 0)
					sb.Append(separator);
				if (urlEncode)
					sb.Append(HttpUtility.UrlPathEncode(key.ToString()));
				else
					sb.Append(key.ToString());
				sb.Append(equality);
				if (urlEncode)
					sb.Append(HttpUtility.UrlPathEncode(value.ToString()));
				else
					sb.Append(value.ToString());

				index++;
			}
			string ret = sb.ToString();
			sb.Length = 0; //destroy memory
			return ret;
		}

		private static string GetTextDictionary(NameValueCollection dictionary, string equality, string separator, bool urlEncode)
		{
			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			int index = 0;
			foreach (string key in dictionary.Keys)
			{
				string value = dictionary[key];
				if (index > 0)
					sb.Append(separator);
				if (urlEncode)
					sb.Append(HttpUtility.UrlPathEncode(key.ToString()));
				else
					sb.Append(key.ToString());
				sb.Append(equality);
				if (urlEncode)
					sb.Append(HttpUtility.UrlPathEncode(value.ToString()));
				else
					sb.Append(value.ToString());
				index++;
			}
			string ret = sb.ToString();
			sb.Length = 0; //destroy memory
			return ret;
		}



	}
}

Page Example (AsyncPage.aspx):
-------------------------------------------------------------------------------
<%@ Page Async="true" Language="C#" AutoEventWireup="true" CodeFile="AsyncPage.aspx.cs" Inherits="AsyncPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">" >http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></a>

<html xmlns="<a href="http://www.w3.org/1999/xhtml">" >http://www.w3.org/1999/xhtml"></a>
<head runat="server">
    <title></title>
    <script type="text/javascript">
    	function AJAXCall(url, callBack, postData) {
    		//setup the callback
    		var out = callBack;
    		if (!out) {
    			out = function(text) { return; }
    		}

    		//setup the request
    		var request = null;
    		if (window.XMLHttpRequest)
    			request = new XMLHttpRequest();
    		else if (window.ActiveXObject)
    			request = new ActiveXObject("Microsoft.XMLHTTP");
    		else
    			return false;

    		//true for async..
    		request.open("POST", url, true);

    		//setup the handle of the request when the status changes
    		request.onreadystatechange = function() {
    			if (request && request.readyState == 4) {
    				//if (request.status == 200)
    				out(request.responseText);

    			}
    		}
    		//setup the request headers
    		request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

    		//send the request
    		if (postData)
    			request.send(postData);
    		else
    			request.send("");
    	}

    	function callback(data) {
    		alert('got here: ' + data);
    	}

    	function button1() {
    		AJAXCall("AsyncPage.aspx?LongFunction=1", callback, "testing=1");
    	}   	

    	function button2() {
    		AJAXCall("AsyncPage.aspx?ShortFunction=1", callback, "testing=1");
    	}

    	function button3() {
    		AJAXCall("AsyncPage.aspx?UrlFunction=1", callback, "testing=1");
    	}

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
		<asp:Label ID="lbl1" runat="server" />
		<input type="button" id="testbutton1" value="TestLong" onclick="javascript:button1();" style="width:100px;Height:25px;" />
		<input type="button" id="testbutton2" value="TestShort" onclick="javascript:button2();" style="width:100px;Height:25px;" />
		<input type="button" id="testbutton3" value="TestUrl" onclick="javascript:button3();" style="width:100px;Height:25px;" />
    </div>
    </form>
</body>
</html>

Code Behind (AsyncPage.aspx.cs):
-------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Threading;
using AsyncStuff;

public partial class AsyncPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {		
		if (AsyncCall.IsRunningAsync(Page))			
			CalledAsync(); //function is run when a page calls itself asychronously

		//a query variable triggers this page to run a different async function (use AJAX Call to this same url with this query variable)
		//these are single-run checked already, so you don't have to worry about running them more than once
		if (Request.QueryString["LongFunction"] != null)		
			AsyncCall.RunAsynchronously(Page, AfterLong, "Long call");

		if (Request.QueryString["ShortFunction"] != null)
			AsyncCall.RunAsynchronously(Page, AfterShort);

		if (Request.QueryString["UrlFunction"] != null)
			AsyncCall.RunAsynchronously("/AsyncTest.aspx?test=1", Page);
				
		//Normal Page load		
		lbl1.Text = "Just sitting here";
    }

	//this stuff called on the async thread
	protected void CalledAsync()
	{
		//stuff done during async
		
		if (Request.QueryString["LongFunction"]!=null)
		{
			//crunch some numbers to waste some time
			for(int i = 1; i<565535; i++)
			{
				decimal num = (decimal)DateTime.Now.Millisecond * (decimal)(new Random(DateTime.Now.Millisecond)).NextDouble();
				num += num;
			}
			Response.Write("Success");
		}
		else if (Request.QueryString["ShortFunction"] != null)
		{
			Response.Write("Short Call Was Run");
		}

		Response.End(); //do not show regular page contents
	}

	//this stuff called on the page thread after the async call returns
	protected void AfterLong(AsyncCall.AsyncState state)
	{
		//this is an example of using the response stream directly, you can use state.GetResponseText() to accomplish this same thing
		StreamReader sr = new StreamReader(state.Response.GetResponseStream());
		string pageContent = sr.ReadToEnd();
		if (pageContent.Contains("Success"))		
			Response.Write(state.Parameters[0].ToString());
		else		
			Response.Write("Failure");

		Response.End();
	}

	//this stuff called on the page thread after the async call returns
	protected void AfterShort(AsyncCall.AsyncState state)	
	{		
		string text = state.GetResponseText();
		if (text!=null)
			Response.Write(text);
		Response.End();
	}
}

source

IE6 browser warning

	var $buoop = {} 
$buoop.ol = window.onload; 
window.onload=function(){ 
 if ($buoop.ol) $buoop.ol(); 
 var e = document.createElement("script"); 
 e.setAttribute("type", "text/javascript"); 
 e.setAttribute("src", "<a href="http://browser-update.org/update.js");" >http://browser-update.org/update.js");</a> 
 document.body.appendChild(e); 
}

source

Cross-Browser Auto Vertical/Horizontal Centering (Chrome & Forms Compatible)

<style type="text/css">	
        html,body,form {height:100%;margin:0px;padding:0px;}
	html{height:100%;}
	body{height:96%;text-align:center;}/*height 96% fixes scrollbar problems*/
					   /*remove text-align for left justification*/
	form{display:block;}/*chrome & forms*/
	#page{display:table;overflow:hidden;margin:0px auto;padding:0px;min-height:100%;}

	*:first-child+html #page {position:relative;}/*ie7*/
	* html #page{position:relative;}/*ie6*/

	#content_container{display:table-cell;vertical-align: middle;}
	*:first-child+html #content_container{position:absolute;top:50%;}/*ie7*/
	* html #content_container{position:absolute;top:50%;}/*ie6*/

	*:first-child+html #content{position:relative;top:-50%;left:-50%;}/*ie7*/
	* html #content{position:relative;top:-50%;left:-50%;}/*ie6*/

	#page{height:100%;width:100%;}
</style>

<body>
<div id="page">
       <div id="content_container">
               <div id="content">

<!-- centered content here -->

		</div>
       </div>
</div> 
</body>

source

Visitor Info (Browser, OS, Window Dimensions, Screen Resolution)

//-- Start of Browser, Version and OS
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

//-- Start of Window Dimensions
var winW = 0, winH = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    winW = window.innerWidth;
    winH = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    winW = document.documentElement.clientWidth;
    winH = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    winW = document.body.clientWidth;
    winH = document.body.clientHeight;
  }

//-- Start of Screen Resolution
var vertical=screen.height
var horizontal=screen.width

source

Open web browser

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "<a href="http://www.google.com";" >http://www.google.com";</a>
process.Start();

source