2014-10-16 42 views
0

試圖重新設計一個頁面,我不再去編寫代碼了,所以我非常生疏。我正試圖獲取遠程網絡服務器上的服務狀態。我在ASP中使用WMI服務,經過大量閱讀後確定ServiceController是更好的選擇。我想根據Page_Load上的服務狀態更改div的類別。這是迄今爲止我所擁有的,並且我一直堅持到目前爲止沒有任何工作。我將在Running,Stopped,Pausesed事件上顯示綠色,紅色或橙色的光圖像 - 所有其他事件都將成爲關閉的圖像。從遠程服務器獲取服務狀態並顯示在div標籤中VB

Imports System 
Imports System.ServiceProcess 
Imports System.Diagnostics 
Imports System.Threading 
Imports System.Web.UI.Page 

Public Class _Default 
Inherits Page 


Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load 
    Dim process As String = "myservicename" 
    Dim pserver As String = "myremoteserver" 
    Dim sc = New ServiceController(process, pserver) 

    If sc.Status = ServiceControllerStatus.Running Then 
     <change div tag here> 
    End If 
End Sub 
End Class 

頁面上的DIV是目前設置爲:

<!DOCTYPE html> 
<html lang="en"> 
<head runat="server" >  
..... 
</head> 
<body> 
    <form ... 
    <div class="info"> 
     ... 
     <div class="element">Service Manager<div id="smstatus" class="icon" runat="server"></div>  
    </div> 

我曾試着撥打smstatus.Attributes.Add沒有成功。沒有試圖調用smstatus id生成任何東西。我可以從哪裏開始使用一些幫助。總結:我希望能夠檢查另一臺服務器上的服務狀態,然後將div或面板中的類更改爲適當的類。提前致謝。

回答

0

我發現了這個問題。該頁面沒有被正確地繼承。這是我不得不

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="default.aspx.vb" Inherits="default" %> 

這是我需要

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="default.aspx.vb" Inherits="Datadash._default" %>