Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening ASP page run my

Status
Not open for further replies.

josephk73

Technical User
Aug 1, 2002
115
GB
Guys,

I was wondering if you can help its concerning an ASP 2.0 page I'm trying to write.

I'm no ASP expert (infact this is the first one I've ever written), so the question I pose here may seem pretty simple, but please put up with me.

The code so far is as follows:

<html>
<body>

<form action="helloworld.asp" method="post">
Server to check:<input type="text" name="Server" size="20" />
<input type="submit" value="Check my server" />
</form>


<%

Dim Server

'Create server heading
Server=Request.Form("Server")
If Server<>""Then
Response.Write("<b><font size=14>System Check: </b></font>""<b><font size=14>" &(Ucase(Server))&"</b></font>" &"<br>")
End If


Response.Write("" & "<br>")
Response.Write("" & "<br>")
Response.Write("" & "<br>")
Response.Write("" & "<br>")
Response.Write("<b>GENERAL SYSTEM INFORMATION</b>" & "<br>")
Response.Write("-------------------------------------------" & "<br>")
ObjFile.WriteLine "GENERAL SYSTEM INFORMATION"
ObjFile.WriteLine "============================"


%>

</body>
</html>






When I load up my webpage, all my VB code runs at the time the page loads, which is not the desired effect I want. As you can see I have a button called 'Check my server' and an input box called 'Server'.

I only want the code to run, AFTER the input box has been filled out and the 'Check my server' button is pressed.

I guess I'll need some kind of onclick event for the button and also to seperate the vb code and something else as well, but I'm not sure what.

So, if any of you clever guys can point me in the right direction, I would be most grateful.

 
Just move the end if to after the last objfile.writeline
Code:
Dim Server

'Create server heading
Server=Request("Server")

    If Server<>""Then
        Response.Write("<b><font size=14>System Check: </b></font>""<b><font size=14>" &(Ucase(Server))&"</b></font>" &"<br>")

Response.Write("" & "<br>")
Response.Write("" & "<br>")
Response.Write("" & "<br>")
Response.Write("" & "<br>")
Response.Write("<b>GENERAL SYSTEM INFORMATION</b>" & "<br>")
Response.Write("-------------------------------------------" & "<br>")
ObjFile.WriteLine "GENERAL SYSTEM INFORMATION"
ObjFile.WriteLine "============================"
End If

}...the bane of my life!
 
Thanks GuitarDave78 - that works, you rock.

I dont want to sound greedy, but I'm building up my page and I bet I encouter a few other problems. Please look out for any other pleas for help -:)

Cheers!!!!
 
Without this forums help I would never have been able to do my job.
There are posts asking for help that I posted in 2001!!
(thread707-130846)

}...the bane of my life!
 
Thanks guys (especially guitardave78) for the last bit of help.

I've now extended the code to perform a WMI query as follows:


'display operating system installed
bolColOperatingSystems=False

Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objOperatingSystem in colOperatingSystems
If InStr(objOperatingSystem.Name, "2000")Then
bolColOperatingSystems=True
Response.Write("Operating System is: " & objOperatingSystem.Caption & " " & _
objOperatingSystem.Version & "<br>")
End If
Next


This normally works in a VB script, but I'm not getting any output in the browser about the server I'm connecting to.(ps I am getting output for the first part of the script). Can you use WMI in ASP?

Any suggestions again (pretty please!)
 
guitardave78 - thanks for the link and of course your time in finding it for me. Much appreciated.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top