The beginning.

Discussion in 'ASP .Net' started by Qwert, Mar 17, 2005.

  1. Qwert

    Qwert Guest

    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.
     
    Qwert, Mar 17, 2005
    #1
    1. Advertising

  2. Qwert

    Qwert Guest

    The browser does give an error: Line 4, ";" is expected.
    Isn't ";" used for "C#".
    Page language is set to "VB".


    "Qwert" <> schreef in bericht
    news:...
    > 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.
    >
    >
     
    Qwert, Mar 17, 2005
    #2
    1. Advertising

  3. 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...
    ======================

    "Qwert" <> wrote in message
    news:...
    > 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.
     
    Juan T. Llibre, Mar 17, 2005
    #3
  4. Qwert

    Qwert Guest

    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.


    "Juan T. Llibre" <> schreef in bericht
    news:ew9vH$...
    > 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...
    > ======================
    >
    > "Qwert" <> wrote in message
    > news:...
    >> 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.

    >
    >
     
    Qwert, Mar 17, 2005
    #4
  5. 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...
    ======================

    "Qwert" <> wrote in message
    news:...
    > 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.
    >
    >
    > "Juan T. Llibre" <> schreef in bericht
    > news:ew9vH$...
    >> 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...
    >> ======================
    >>
    >> "Qwert" <> wrote in message
    >> news:...
    >>> 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.

    >>
    >>

    >
    >
     
    Juan T. Llibre, Mar 17, 2005
    #5
  6. Qwert

    Qwert Guest

    > 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 Español
    > Ven, y hablemos de ASP.NET...
    > ======================
    >
    > "Qwert" <> wrote in message
    > news:...
    >> 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.
    >>
    >>
    >> "Juan T. Llibre" <> schreef in bericht
    >> news:ew9vH$...
    >>> 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...
    >>> ======================
    >>>
    >>> "Qwert" <> wrote in message
    >>> news:...
    >>>> 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.
    >>>
    >>>

    >>
    >>

    >
    >
     
    Qwert, Mar 17, 2005
    #6
  7. 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 Español
    Ven, y hablemos de ASP.NET...
    ======================

    "Qwert" <> wrote in message
    news:...
    >> 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 Español
    >> Ven, y hablemos de ASP.NET...
    >> ======================
    >>
    >> "Qwert" <> wrote in message
    >> news:...
    >>> 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.
    >>>
    >>>
    >>> "Juan T. Llibre" <> schreef in bericht
    >>> news:ew9vH$...
    >>>> 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...
    >>>> ======================
    >>>>
    >>>> "Qwert" <> wrote in message
    >>>> news:...
    >>>>> 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.
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    Juan T. Llibre, Mar 17, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raj Mudaliar
    Replies:
    0
    Views:
    2,312
    Raj Mudaliar
    Jul 14, 2003
  2. Matt
    Replies:
    1
    Views:
    645
    Matthew Speed
    Nov 8, 2003
  3. newgenre
    Replies:
    1
    Views:
    319
    Curt_C [MVP]
    Apr 14, 2004
  4. Zenobia
    Replies:
    1
    Views:
    380
    Raterus
    Jun 17, 2004
  5. Jesse B.
    Replies:
    9
    Views:
    260
    Jesse B.
    Mar 27, 2010
Loading...

Share This Page