Jquery to check Mobile Device or Browser

To check whether the page is acceded from mobile device or browser please use below script


//*******************************Jquery For Mobile Device Start ************************************/

$(document).ready(function(){

var mobile = (/iphone|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));

if (mobile)
{
alert("MOBILE DEVICE!!");

//Retriev Browser URL
var url = window.location.pathname;

//Get Page Name From browser URL with extenstion
var filename = url.substring(url.lastIndexOf('/')+1);

}
else
{
alert("NOT A MOBILE DEVICE!!");
}

});
//*******************************Jquery For Mobile Device End************************************/

Lie Jquery file URL:

https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js

ASP.Net Post Form From Code Behind

To Submit or Post Form’s Data from Code Behind use below code


 protected void PostData(object sender, EventArgs e)
{
	NameValueCollection collections = new NameValueCollection();
    collections.Add("FirstName", txtFirstName.Text.Trim());
    collections.Add("LastName", txtLastName.Text.Trim());
    string remoteUrl = "http://DemoPage.aspx";
 
    string html = "<html><head>";
    html += "</head><body onload='document.forms[0].submit()'>";
    html += string.Format("<form name='PostForm' method='POST' action='{0}'>", remoteUrl);
    foreach (string key in collections.Keys)
    {
        html += string.Format("<input name='{0}' type='text' value='{1}'>", key, collections[key]);
    }
    html += "</form></body></html>";
    Response.Clear();
    Response.ContentEncoding = Encoding.GetEncoding("ISO-8859-1");
    Response.HeaderEncoding = Encoding.GetEncoding("ISO-8859-1");
    Response.Charset = "ISO-8859-1";
    Response.Write(html);
    Response.End();
}