Saturday, March 31, 2012

The beginning.

Ok,
I have a file 'WeatherPage.aspx' with the following code, basic stuff:
<%@dotnet.itags.org. 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".
"Qwert" <nosp@dotnet.itags.org.nosp.com> schreef in bericht
news:Cpidncmdb6Qw76TfRVnyvg@dotnet.itags.org.casema.nl...
> Ok,
> I have a file 'WeatherPage.aspx' with the following code, basic stuff:
> <%@dotnet.itags.org. 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.
>
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 Espaol
Ven, y hablemos de ASP.NET...
======================
"Qwert" <nosp@dotnet.itags.org.nosp.com> wrote in message
news:Cpidncmdb6Qw76TfRVnyvg@dotnet.itags.org.casema.nl...
> Ok,
> I have a file 'WeatherPage.aspx' with the following code, basic stuff:
> <%@dotnet.itags.org. 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.
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</h3>
This sample demonstrates how to manipulate the <asp:label>
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.
"Juan T. Llibre" <nomailreplies@dotnet.itags.org.nowhere.com> schreef in bericht
news:ew9vH$uKFHA.1948@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
> 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 Espaol
> Ven, y hablemos de ASP.NET...
> ======================
> "Qwert" <nosp@dotnet.itags.org.nosp.com> wrote in message
> news:Cpidncmdb6Qw76TfRVnyvg@dotnet.itags.org.casema.nl...
>
>
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 Espaol
Ven, y hablemos de ASP.NET...
======================
"Qwert" <nosp@dotnet.itags.org.nosp.com> wrote in message
news:CpOdnY2NHqHpHKTfRVnyiw@dotnet.itags.org.casema.nl...
> 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</h3>
> This sample demonstrates how to manipulate the <asp:label>
> 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.
>
> "Juan T. Llibre" <nomailreplies@dotnet.itags.org.nowhere.com> schreef in bericht
> news:ew9vH$uKFHA.1948@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
>
> 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.

> ( You did install the .NET Framework, right ? )
> Juan T. Llibre
> ASP.NET MVP
> http://asp.net.do/foros/
> Foros de ASP.NET en Espaol
> Ven, y hablemos de ASP.NET...
> ======================
> "Qwert" <nosp@dotnet.itags.org.nosp.com> wrote in message
> news:CpOdnY2NHqHpHKTfRVnyiw@dotnet.itags.org.casema.nl...
>
re:
> Thanks.
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 Espaol
Ven, y hablemos de ASP.NET...
======================
"Qwert" <nosp@dotnet.itags.org.nosp.com> wrote in message
news:-b6dnYlGzYMPDaTfRVnyiw@dotnet.itags.org.casema.nl...
> 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.

>

0 comments:

Post a Comment