not recognizing ASP.NET code

windows

Guest
Hello,

I've got the following aspx file:

<%@Page Explicit="True" Language="VB" Debug="True" %>
<html>
<script runat="server">
Sub OKButton_Click(Sender As Object, E As EventArgs)
Dim UserAge, DogAge As Integer
UserAge = Age.Text
DogAge = UserAge / 7
Message.Text="If you were a dog, you'd be " & _
DogAge & " years old."
End Sub
</script>
<body>
<h1>If You Were A Dog</h1>
<form runat="server">
How old are you?<br>
<asp:textbox id="Age" runat="server"/>
<asp:button text="OK" onclick="OKButton_Click"
runat="server"/><br>
<asp:label id="Message" runat="server"/>
</form>
</body>
</html>

But it gives me an error when I try to run it in IE. It says there's an error on line 4 char 5, expecting ';'. Also, the texbox and button do not show up on the bottom. My feeling is that it's not recognizing asp code and the script is defaulting to javascript or something. If I add language="VB" to the script tag (<script Language="VB" runat="server">) it no longer gives me the error, but the textbox and button still don't appear. I've got Visual Studios .NET installed on an external drive and a laptop running Windows XP. I'm running my file on the root of the external drive. I assume I installed it correctly since all aspx files appear with the standard icon (i.e. a yellow form). Does anyone have any suggestions?ok is it supported by your host provider?I'm not running this through a hosting provider. I'm running this on my laptop with Windows XP and Visual Studios .NET (framework 1.1) installed. There should be a way for this to work since it works on my home PC which has the exact same settings (OS, VS, IIS, etc.)How are you access it? <!-- m --><a class="postlink" href="http://localhost">http://localhost</a><!-- m --> ???you need to check if the page is Postback then carry on you code.

Check my code, it's kind of similar to yours. I have had similar problem just like yours before. Figure it out!

See the code in action: <!-- m --><a class="postlink" href="http://www.musikahankaraoke.com/restaurant.aspx">http://www.musikahankaraoke.com/restaurant.aspx</a><!-- m -->

I think your missing this: If IsPostBack
<%@ Page Language="VB" Debug="true" %>

<script runat="server">

Dim CusName As String
Dim CusPhone As String
Dim Total As String
Dim strMainItem As String
Dim Menuitem As Double = 0
Dim Sidesalad As Single = 2.5
Dim Sidelemon As Single = 1.75

Sub Submit_Click(Sender As Object, E As EventArgs)

If IsPostBack

Call ValListBox()

CusName = txtname.Text
CusPhone = Trim(txtphone.Text)

'Check if the customer enter a name and phone number
'and also check if the phone field is numeric
If CusName = "" And CusPhone = "" Then
lblerror.Text = "Empty fields, please enter your name and phone number"
lblerror.visible = True

ElseIf CusName = "" Then
lblerror.Text = "Please enter your name"
lblerror.visible = True

ElseIf CusPhone = "" Then
lblerror.Text = "Please enter a phone number"
lblerror.visible = True

ElseIf Not IsNumeric(CusPhone) Then
lblerror.Text = "Only Numeric/Number is allowed in the phone field"
lblerror.visible = True

ElseIf IsNumeric(CusName) = True Then
lblerror.Text = "No Numeric is allowed in the name field"
lblerror.visible = True

Else

lbldisname.Text = "Name: " & CusName
lbldisphone.Text = "Phone #: " & CusPhone
lbldisitem.Text = "Main Item: " & strMainItem
lblconfirm.Text = "Order Confirmation:"

lblconfirm.visible = True
lbldisname.visible = True
lbldisphone.visible = True
lbldisitem.visible = True

'Check customer side item order
If Chksalad.Checked = True And chklemon.Checked = True Then

lblsideorder.Text = "Side Dish: " & "Salad: " & FormatCurrency(Sidesalad) & " and " & "Lemonade: " & FormatCurrency(Sidelemon)
lblsideorder.visible = True

Total = Sidesalad + Sidelemon + Menuitem

lbltotal.Text = "Your total is: " & FormatCurrency(Total)
lbltotal.visible = True

ElseIf Chksalad.Checked = True Then

lblsideorder.Text = "Side Dish: " & "Salad: " & FormatCurrency(Sidesalad)
lblsideorder.visible = true

Sidelemon = 0
Total = Sidesalad + Menuitem

lbltotal.Text = "Your total is: " & FormatCurrency(Total)
lbltotal.visible = True

ElseIf chklemon.Checked = True Then

lblsideorder.Text = "Side Dish: " & "Lemonade: " & FormatCurrency(Sidelemon)
lblsideorder.visible = true

Total = Sidelemon + Menuitem
lbltotal.Text = "Your total is: " & FormatCurrency(Total)
lbltotal.visible = True

ElseIf Chksalad.Checked = False And chklemon.Checked = False Then


Total = Menuitem
lblsideorder.Text = "No Side Dish Order"
lblsideorder.visible = true
lbltotal.Text = "Your total is: " & FormatCurrency(Total)
lbltotal.visible = True

End If

End If

End If

End Sub


Sub ValListBox()

'Check customer main item order

If Listboxmenu.SelectedIndex >= 0 Then
strMainItem = Listboxmenu.SelectedItem.Value
End If

'Display selected item cost
If Listboxmenu.SelectedIndex = 0 Then
Menuitem = 0
strMainItem = "No Main Item"
ElseIf Listboxmenu.SelectedIndex = 1 Then
Menuitem = 6.75
strMainItem = "CheeseBurger - $6.75"
ElseIf Listboxmenu.SelectedIndex = 2 Then
Menuitem = 5.5
strMainItem = "HamBurger - $5.50"
ElseIf Listboxmenu.SelectedIndex = 3 Then
Menuitem = 4.9
strMainItem = "HammusBurger - $4.90"
Else
Menuitem = 0
End If

End Sub

Sub btnreset_Click(Sender As Object, E As EventArgs)

txtname.Text = ""
txtphone.Text = ""
lbldisname.Text = ""
lbldisphone.Text = ""
lbldisitem.Text = ""
lblsideorder.Text = ""
lbltotal.Text = ""
lblconfirm.Text = ""
lblerror.text = ""
Chksalad.Checked = False
chklemon.Checked = False

End Sub

</script>
<!--Author: Dexter Zafra :) - CIS120 Prof. John Schumacher-->

<html>
<head>
<title>Restaurant Order Confirmation</title>
<style type="text/css" media="screen">@import "cssrestaurant.css";</style>
</head>
<body>
<div class="div2">
<h3>Dexter Restaurant Order Confirmation</h3>
Visit us at <a href=http://www.htmlforums.com/archive/index.php/"http://www.ex-designz.net" title="visit our website">www.ex-designz.net</a>
<div class="content2">
CIS120 - Prof. John Schumacher
<form runat="server">
<asp:Label ID="lblerror" runat="server" class="cred" visible=false />
<br />
Your Name: <asp:Textbox runat="server" ID="txtname" class="textbox" width="180px"/>
<br />
Phone #:</font> <asp:Textbox runat="server" ID="txtphone" class="textbox" width="120px"/>
<br />
Main Item:
<asp:Dropdownlist runat="server" ID="Listboxmenu" class="cselect" width="170px">
<asp:Listitem selected></asp:Listitem>
<asp:Listitem Value="6.75">CheeseBurger - $6.75</asp:Listitem>
<asp:Listitem Value="5.50">HamBurger - $5.50</asp:Listitem>
<asp:Listitem Value="4.90">HammusBurger - $4.90</asp:Listitem>
</asp:Dropdownlist>
<br />
Side Items:
<br />
Salad $2.50: <asp:checkbox runat="server" ID="Chksalad"/>
<br />
Lemonade $1.75: <asp:checkbox runat="server" ID="chklemon"/>
<br />
<br />
<asp:Button runat="server" OnClick="Submit_Click" class="submit" Text="Submit"/> <asp:Button runat="server" OnClick="btnreset_Click" class="submit" Text="Reset"/>
<br />
<br />
</form>
</div>

<div class="content2">
<strong><asp:Label ID="lblconfirm" runat="server" visible=false /></strong>
<br />
<asp:Label ID="lbldisname" runat="server" visible=false />
<br />
<asp:Label ID="lbldisphone" runat="server" visible=false />
<br />
<asp:Label ID="lbldisitem" runat="server" visible=false />
<br />
<asp:Label ID="lblsideorder" runat="server" visible=false />
<br />
<br >
<asp:Label ID="lbltotal" runat="server" visible=false />
</div>
</div>
</body>
</html>

Dexter
<!-- w --><a class="postlink" href="http://www.ex-designz.netI">www.ex-designz.netI</a><!-- w --> do not beleive the code is being compiled dexter, if you looked at the issue.

he might need to just register the ASP.net extension in IIS correctly by using the command line
the app is located in the windows directory
%windir%\Microsoft.net\Framework\[v]\aspnet_iisreg -i

where v is the version each version is in its own sub-folder.
 
Back
Top