please help me sir..
error :
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0120: An object reference is required for the non-static field, method, or property 'pingtest.WebForm1.Label1'
Source Error:
|
Line 22: try
Line 23: {
Line 24: Label1.Text=("Pinging" + address);
Line 25: Ping pingClass = new Ping();
Line 26: PingReply pingReply = pingClass.Send(address, timeout);
|
Source File: c:\Users\Administrator\Documents\Visual Studio 2012\Projects\pingtest\pingtest\WebForm1.aspx.cs Line: 24
Show Detailed Compiler Output:
Show Complete Compilation Source:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.9214.0
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace pingtest
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
long time = PingAddress("www.youtube.com", 1000);
}
}
private static long PingAddress(string address, int timeout)
{
try
{
Label1.Text = ("Pinging" + address);
Ping pingClass = new Ping();
PingReply pingReply = pingClass.Send(address, timeout);
return pingReply.RoundtripTime;
}
catch (Exception e)
{
}
return -1;
}
}
}