Nieuw lid |
|
Hoi ik ben begonnen met het mijzelf verdiepen in ASP.NET.
Nu probeer ik een scriptje te schrijven om de kleuren van een pagina te veranderen door een radiobutton aan te klikken.
Nu heb ik al wel een manier waarop het anders werkt maar ik wil graag weten waarom ik in de volgende code deze error krijg:
Citaat: Compiler Error Message: BC30086: 'Else' must be preceded by a matching 'If' or 'ElseIf'.
Source Error:
Line 11:
Line 12: If green.Checked Then strBackgrnd = "green"
Line 13: ElseIf yellow.Checked Then strBackgrnd = "yellow"
Line 14: ElseIf red.Checked Then strBackgrnd = "red"
Line 15: Else blue.Checked Then strBackgrnd= "blue"
Source File: D:WebsitesASP.NET OefKleurveranderen.aspx Line: 13
<%@ Page Language="VB" %>
<script runat="server">
Dim strBackgrnd As String = "white"
Sub color_change(s As Object, e As EventArgs)
If green.Checked Then strBackgrnd = "green"
ElseIf yellow.Checked Then strBackgrnd = "yellow"
ElseIf red.Checked Then strBackgrnd = "red"
Else blue.Checked Then strBackgrnd= "blue"
End If
End Sub
</script>
<html>
<head>
</head>
<body bgcolor="<%=strBackgrnd%>">
<form runat="server">
<h2>Kies uw eigen achtergrond
</h2>
<p>
<asp:RadioButton id="green" runat="server" Text="Groen" GroupName="color" AutoPostBack="true" OnCheckedChanged="color_change"></asp:RadioButton>
<asp:RadioButton id="yellow" runat="server" Text="Geel" GroupName="color" AutoPostBack="true" OnCheckedChanged="color_change"></asp:RadioButton>
<asp:RadioButton id="red" runat="server" Text="Rood" GroupName="color" AutoPostBack="true" OnCheckedChanged="color_change"></asp:RadioButton>
<asp:RadioButton id="blue" runat="server" Text="Blauw" GroupName="color" AutoPostBack="true" OnCheckedChanged="color_change"></asp:RadioButton>
</p>
</form>
</body>
</html>
<%@ Page Language="VB" %> <script runat="server"> Dim strBackgrnd As String = "white" Sub color_change(s As Object, e As EventArgs) If green.Checked Then strBackgrnd = "green" ElseIf yellow.Checked Then strBackgrnd = "yellow" ElseIf red.Checked Then strBackgrnd = "red" Else blue.Checked Then strBackgrnd= "blue" End If End Sub </script> <html> <head> </head> <body bgcolor="<%=strBackgrnd%>"> <form runat="server"> <h2>Kies uw eigen achtergrond </h2> <p> <asp:RadioButton id="green" runat="server" Text="Groen" GroupName="color" AutoPostBack="true" OnCheckedChanged="color_change"></asp:RadioButton> <asp:RadioButton id="yellow" runat="server" Text="Geel" GroupName="color" AutoPostBack="true" OnCheckedChanged="color_change"></asp:RadioButton> <asp:RadioButton id="red" runat="server" Text="Rood" GroupName="color" AutoPostBack="true" OnCheckedChanged="color_change"></asp:RadioButton> <asp:RadioButton id="blue" runat="server" Text="Blauw" GroupName="color" AutoPostBack="true" OnCheckedChanged="color_change"></asp:RadioButton> </p> </form> </body> </html>
Alvast bedankt!
|