Pages

Ads 468x60px

For New Update Use this Link http://dotnethubs.blogspot.in/ Offer for you

.

Tuesday, 12 March 2013

How to Get Screen Resolution of User or Client Machine using java script

Introduction
Here I will explain how to Get Monitor screen resolution using JavaScript or Get screen resolution of user in JavaScript.
Description:
To get user screen resolution we need to write the code like as shown below
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get Screen Resolution using JavaScript</title>
<script type="text/javascript" language="javascript">
function GetResolution(){
document.getElementById("txtWidth").value = screen.width;
document.getElementById("txtHight").value = screen.height;
}
</script>
</head>
<body onload="GetResolution();">
<table>
<tr><td align="center" colspan="2">
<b><span style="color: #990000;">Your Screen Resolution </span></b></td></tr>
<tr>
<td>Width :</td>
<td valign="middle"><input type="text" size="5" name="txtWidth" id="txtWidth">px</td>
</tr>
<tr>
<td>Height :</td>
<td valign="middle"><input type="text" size="5" name="txtHight" id="txtHight">px</td>
</tr>
</table>
</body>
</html>
Live Demo
For live demo check below of your screen resolution details
Your Screen Resolution
Width : px
Height : px
How to Get Screen Resolution of User or Client Machine

Monday, 11 March 2013

Check Internet Connection in Asp.net using C#, VB.NET

Check Internet Connection in Asp.net using C#, VB.NET 
Introduction

Here I will explain how to check internet connectivity of system in 
asp.net and C#.net VB.NET.
Description
    In my previous article i have explained
jQuery Get Number of Facebook likes, Shares, Comments using asp.net.  Now I will explain how to check internet connectivity of system in asp.net using C# and VB.NET.

We can check internet connectivity of system by downloading data of one website from server for that write code like as shown below
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Check Internet Connection Availability using Asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button runat="server" ID="btnCheck" Text="Check Internet Connectivity" OnClick="btnCheck_Click" />
<asp:Label runat="server" ID="lbltxt" />
</div>
</form>
</body>
</html>
Now in code behind add the following namespaces
C# Code
using System;
using System.Net;
After that write the following code in code behind
protected void btnCheck_Click(object sender, EventArgs e)
{
WebClient client = new WebClient();
byte[] datasize = null;
try
{
datasize = client.DownloadData("http://www.google.com");
}
catch (Exception ex)
{
}
if (datasize != null && datasize.Length > 0)
lbltxt.Text = "Internet Connection Available.";
else
lbltxt.Text = "Internet Connection Not Available.";
}
VB.NET Code

Imports System.Net
Partial Class VBCode
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub btnCheck_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim client As New WebClient()
Dim datasize As Byte() = Nothing
Try
datasize = client.DownloadData("http://www.google.com")
Catch ex As Exception
End Try
If datasize IsNot Nothing AndAlso datasize.Length > 0 Then
lbltxt.Text = "Internet Connection Available."
Else
lbltxt.Text = "Internet Connection Not Available."
End If
End Sub
End Class
Demo

Javascript Get User IP Address, Latitude, Longitude, Country, City, State Details

Javascript Get User IP Address, Latitude, Longitude, Country, City, State Details

Javascript Get User IP Address,Latitude,Longitude,Country,City,State Details

Introduction
Here I will explain how to get user current location details IP address, country, city, state, latitude and longitude using smart-ip json url in JavaScript using asp.net in C#.
Description:
   In my previous articles I expained how to get
jQuery Get Number of Facebook likes, Shares, Comments using asp.net.
Now I will explain how to get current user location details IP address, country, city, state, latitude and longitude using smart-ip json url in JavaScript

To get current user location details I am using smart-ip.net json string to get all the information for that you need to write the following code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get User Details IP Address, city, country, state, latitude, longitude </title>
<script src="http://code.jquery.com/jquery-1.8.2.js" type="text/javascript"></script>
<script type="text/javascript">
var strip, strcountry, strcity, strregion, strlatitude, strlongitude, strtimezone
function GetUserInfo(data) {
strip = data.host; strcountry = data.countryName; strcity = data.city;
strregion = data.region; strlatitude = data.latitude; strlongitude = data.longitude;
strtimezone = data.timezone;
}
$(function () {
BindUserInfo();
})
function BindUserInfo() {
document.getElementById('lblIP').innerHTML = strip;
document.getElementById('lblCountry').innerHTML = strcountry;
document.getElementById('lblCity').innerHTML = strcity;
document.getElementById('lblregion').innerHTML = strregion;
document.getElementById('lbllatitude').innerHTML = strlatitude;
document.getElementById('lbllongitude').innerHTML = strlongitude;
document.getElementById('lbltimezone').innerHTML = strtimezone;
}
</script>
<script type="text/javascript" src="http://smart-ip.net/geoip-json?callback=GetUserInfo"></script>
</head>
<body>
<div>
<table id="tbDetails" cellpadding="2" cellspacing="2" style=" border:1px solid #000; font-family:Verdana;" >
<tr style="background-color:#DC5807; color:White; font-weight:bold">
<td colspan="2" align="center">User Information</td>
</tr>
<tr style="border:solid 1px #000000">
<td align="right"><b>IP:</b></td>
<td><label id="lblIP"/></td>
</tr>
<tr>
<td align="right"><b>Country:</b></td>
<td><label id="lblCountry"/></td>
</tr>
<tr>
<td align="right"><b>City:</b></td>
<td><label id="lblCity"/></td>
</tr>
<tr>
<td align="right"><b>Region:</b></td>
<td><label id="lblregion"/></td>
</tr>
<tr>
<td align="right"><b>latitude:</b></td>
<td><label id="lbllatitude"/></td>
</tr>
<tr>
<td align="right"><b>Longitude:</b></td>
<td><label id="lbllongitude"/></td>
</tr>
<tr>
<td align="right"><b>Time Zone:</b></td>
<td><label id="lbltimezone"/></td>
</tr>
</table>
</div>
</body>
</html>


Show Demo


For live demo check below of your current location details

User Information
IP:
Country:
City: indore
Region: M.P
latitude:
Longitude:
Time Zone: India/M.P


-------------------------------------------------------------------------------------------------------------
 

..




New Updates

Related Posts Plugin for WordPress, Blogger...

Related Result