
hi,
use following namespaces
----------------------------------
using System.Runtime;
using System.Runtime.InteropServices;
-----------------------------------
create a class
class CheckInternet
{
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
//Creating a function that uses the API function...
public static bool IsConnectedToInternet()
{
int Desc;
return InternetGetConnectedState(out Desc, 0);
}
}
in code behind of ur page on load or on any event on which u want to check..
bool CheckConnection=CheckInternet.IsConnectedToInternet()
if(CheckConnection==true)
{
//run your code
}
else
{
MessageBox.Show("No internet connection");
}
It is running n i used it yesterday in my windows application..
Akiii, if this helps please login to Mark As Answer. | Alert Moderator