The beginning.

  • Thread starter Thread starter Qwert
  • Start date Start date
Q

Qwert

Ok,

I have a file 'WeatherPage.aspx' with the following code, basic stuff:

<%@ Page language="VB" %>
<script runat="server">

Shared rand As Random = New Random()
Function GetForecast(zip As String) As String
Dim ret As String = String.Empty
Select rand.Next(5)
Case 0
ret = "Sunny and warm"
Case 1
ret = "Partly cloudy and chilly"
Case 2
ret = "Cold with a chance of snow"
Case 3
ret = "Rain"
Case 4
ret = "Foggy and damp"
End Select
Return ret
End Function

</script>
<html>
<body>
<h1>My weather forecast page</h1>
<p>The weather for zipcode 04090 is: <%= GetForecast("04090") %> </p>
<p>The weather for zipcode 90210 is: <%= GetForecast("90210") %> </p>
<p>The weather for zipcode 84101 is: <%= GetForecast("84101") %> </p>
<p>The weather for zipcode 80014 is: <%= GetForecast("80014") %> </p>
<p>The weather for zipcode 02101 is: <%= GetForecast("02101") %> </p>
</body>
</html>


my operating system is Windows XP profesional. I use Internet Information
Services 5.1 (IIS).

When I run this page in a webbrowser, the function 'GetForecast' doesn't
display anything ( no error's). All I see is the HTML text. What can I be
doing wrong? I got this code from a tutorial.
Is the code incorrect? Can IIS have incorrect settings?

Thanks.
 
The browser does give an error: Line 4, ";" is expected.
Isn't ";" used for "C#".
Page language is set to "VB".
 
You need to enclose your frunctions within

Sub

End Sub

statements.

If you want the code to execut automatically
when the page loads, use Sub Page_Load :

<script runat="server">
Sub Page_Load(Src as Object, e As System.EventArgs)

....rest of your code

End Sub
<//script>

best,


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
You mean something like this, it does not work either:

<html>

<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Message.Text = "You last accessed this page at: " & DateTime.Now
End Sub
</script>

<body>
<h3><font face="Verdana">Manipulating Server Controls</font></h3>
This sample demonstrates how to manipulate the &lt;asp:label&gt;
server control within
the Page_Load event to output the current time.
<p>
<hr>
<asp:label id="Message" font-size="24" font-bold="true"
runat=server/>
</body>
</html>


I see the HTML in the browser, but not the Message.Text in the label
control.
 
I just pasted your code into
http://asp.net.do/test/vbtest2.aspx

It works fine.

Are you using http://localhost/virtualdirectory/yourfile.aspx ?
Or http://localhost/yourfile.aspx ?
Or http://YourComputerName/virtualdirectory/yourfile.aspx ?
Or http://yourserver.com/directory/yourfile.aspx ?

If you are, and it still doesn't work, try re-registering ASP.NET
from the .NET framework's main directory :

aspnet_regiis -i

( You did install the .NET Framework, right ? )




Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
If you are, and it still doesn't work, try re-registering ASP.NET
from the .NET framework's main directory :

aspnet_regiis -i

It worked.....but weird. Someone already installed .NET Framework. Doesn't
make sense ASP.NET needs a seperate installement....I wasn't there when it
was installed on my comp, maybe you can select an option during installation
that you don't want to install ASP.NET.

3 cheers for spain!

Thanks.
 
re:

You're very much welcome!
Glad it worked!

re:
Someone already installed .NET Framework. Doesn't make sense ASP.NET needs
a seperate installement.

Maybe someone uninstalled/reinstalled IIS ?
That would require re-registering ASP.NET with the new IIS.

re:
3 cheers for spain!

Make that the Dominican Republic... ;-)

Happy coding!
Don't let the bug(ger)s get you!

:-)



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top