An if statement can include an else condition.

The else condition defines the code to be executed if the condition is false.

Example

@Code
Dim price=20
End Code
<html>
<body>
@if price>30 then
    @<p>The price is too high.</p>
Else
    @<p>The price is OK.</p>
End If
</body>
</html>

Note: In the example above, if the first condition is true, it will be executed. The else condition covers "everything else".



Practice Excercise Practice now