View Full Version : I am sure this is simple
WindmillMan
01-28-2004, 10:51 PM
I get an error with the asp.net code that follows:
The error is:
Line: 3
Char: 5
Error: Expected ';'
Code: 0
URL: http:/..........
The Asp.net Code is:
<%@ Page Language="VB" ContentType="text/html" %>
<script runat="server">
Sub ChangeImage(Src As Object, E As EventArgs)
imgBanner.Src= ImagesList.Value
End Sub
</script>
<html>
<head>
<title>Using HTML Server Controls</title>
</head>
<body>
<h2>
Using HTML Server Controls
</h2>
<form runat="server">
<img id="imgBanner" src="img1.gif" runat="server">
<p>
Select an image to display:
<select id="ImagesList" runat="server">
<option value="img1.gif">C#</option>
<option value="img2.gif">UltraDev</option>
<option value="img3.gif">JSP</option>
</select>
<br>
<input type="submit" runat="server" value="Display Image" onServerClick="ChangeImage">
</form>
</body>
</html>
I would very much appreciate information on where the error actually is. Thank You!:
Welcome here !
I think the problem is that the code isn't recognised by the parser as ASP-code, and that you actually get a javascript error or omething like that.
Try enclosing the code in asp-tags, like
<%
Sub ChangeImage(Src As Object, E As EventArgs)
imgBanner.Src= ImagesList.Value
End Sub
%>
<html>
<head>
<title>Using HTML
...
WindmillMan
01-29-2004, 03:11 AM
When I do that, I get the following error:
Line: 3
Char: 1
Error: Syntax error
Code: 0
URL: http:/....
I appreicate your idea but it did not work. I am still confused.:confused:
glenngv
01-29-2004, 03:38 AM
When tags contain runat="server", it is a server control so definitely the problem is not a client-side error.
I've seen this similar code from w3schools
<script runat="server">
Sub change_image(Sender As Object, e As EventArgs)
i1.Src = "../images/" & s1.Value
End Sub
</script><html>
<body>
<form runat="server">
<img id="i1" src="../images/smiley.gif" runat="server"/>
<br />
<p>Select image:
<select id="s1" runat="server">
<option value="smiley.gif">Smiley</option>
<option value="angry.gif">Angry</option>
<option value="stickman.gif">Stickman</option>
</select>
<input type="submit" runat="server" value="Show Image"
OnServerClick="change_image" />
</p>
</form>
</body>
</html>
WindmillMan, where or when do you see the error? In the browser error box or while compiling the page?
If the former, then it is indeed a client-side error so you must post the generated html here for us to see.
WindmillMan
01-29-2004, 03:51 AM
Glennvg
The error occurs when you load the page in the browser. Once you hit OK on the error box to dismiss it, and you view source, you see the following:
<%@ Page Language="VB" ContentType="text/html" %>
<script runat="server">
Sub ChangeImage(Src As Object, E As EventArgs)
Image1.ImageUrl=ImagesList.SelectedItem.Value
Image1.AlternateText=ImagesList.SelectedItem.Text
End Sub
</script>
<html>
<head>
<title>Using the Image Control</title>
</head>
<body>
<h2>Using the Image Control</h2>
<form runat="server">
<asp:Image ID="Image1" ImageUrl="img1.gif" runat="server" />
<p> Select an image to display:
<asp:DropDownList id="ImagesList" runat="server">
<asp:ListItem Value="img1.gif">C#</asp:ListItem>
<asp:ListItem Value="img2.gif">UltraDev</asp:ListItem>
<asp:ListItem Value="img3.gif">JSP</asp:ListItem>
</asp:DropDownList>
<asp:Button text="Display Image" OnClick="ChangeImage" runat="server" />
<asp:textbox runat="server" />
</form>
</body>
</html>
so I guess that means that the server is not processing the asp at all.
Thank You Again!
glenngv
01-29-2004, 03:56 AM
Hmm...the server-side codes are not parsed by the ASP engine. Did you put the .aspx extension on that page?
WindmillMan
01-29-2004, 03:58 AM
Yes it is .aspx
I just looked at the IIS server and it is set to JS for client side scripting which would explain why it must be giving me an JS error because the VBScript that should be executed on the server, is just being sent to the browser... I guess...??
glenngv
01-29-2004, 04:23 AM
Maybe you don't have .NET framework installed on the server.
http://www.w3schools.com/aspnet/aspnet_install.asp
WindmillMan
01-29-2004, 06:18 AM
I just uninstalled and reinstalled IIS and installed .net from Microsoft. I still get the same result. :( I still believe you must be right. Will continue to see if I can find the problem there. Thank You!
glenngv
01-29-2004, 06:33 AM
See if you have the same situation with this (http://www.codingforums.com/showthread.php?s=&threadid=18028#post89962).
WindmillMan
01-29-2004, 07:04 AM
Thanks again Glenngv
No, that is not it either, I backtracked and reinstalled everything again. Still no luck. This is not fun :( I will talk to my local ISP tomorrow and see if they can enable a asp.net server for me. Again Thank You!!:thumbsup:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.