Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Listbox troubles in Visual C#

Posted on 2008-10-23
1
343 Views
Last Modified: 2013-12-17
I am currently making a ajax enabled asp.net 2.0 C# web page using Visual studio.net 2005  that pings 13 servers at timed intervals.

I am wondering:
1. If and how i can use the below mentioned variable svr in the below mentioned loop to be passed as the hostname to ping the various servers as it loops though on page load.

2. If and how i can include a image inside a listbox a part of the loop in the below code snippet  

It errors on PingReply reply = pingSender.Send(hostName, timeout, buffer, options); saying no host exists so it must not be being passed.


protected void Page_Load(object sender, EventArgs e)
    {
        string[] servers = File.ReadAllLines(Server.MapPath("TestFile.txt"));
        foreach (string svr in servers)
        {
          ListBox1.Items.Add(svr + " is Online");
        }
} 
 
And my ping code is

Open in new window

0
Comment
Question by:Figle
1 Comment
 
LVL 7

Accepted Solution

by:
keustermans earned 500 total points
ID: 22793815
found this on the net maybe it will help you
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
 
 
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {     
 
     // This tutorial is provided in part by Server Intellect Web Hosting Solutions http://www.serverintellect.com
 
     // Visit http://www.AspNetTutorials.com for more ASP.NET Tutorials
 
    }
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
    try {
    lblStatus.Text = null;
    Ping ping = new Ping();
    PingReply pingreply = ping.Send(txtHost.Text);
    txtPing.Text += "Address: " + pingreply.Address + "\r";
    txtPing.Text += "Roundtrip Time: " + pingreply.RoundtripTime + "\r";
    txtPing.Text += "TTL (Time To Live): " + pingreply.Options.Ttl + "\r";
    txtPing.Text += "Buffer Size: " + pingreply.Buffer.Length.ToString() + "\r";
 
    }
    catch (Exception err) {
      lblStatus.Text = err.Message;
    }
 }
}

Open in new window

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
c# - Best approach for objects in functions 3 24
SSIS On fail action 5 38
abstract class C# 1 31
ASP.NET Content Page 3 29
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question