ASP.NET Tutorial/Language Basics/if
Use if and "if else" statement with string and boolean type value (C#)
<%@ Page Language="C#" %>
<script runat="server">
void Page_Load(Object Sender, EventArgs e) {
string MyMessage = "Hello";
bool MyBool = true;
if (MyMessage == "Hi" & MyBool) {
Response.Write(MyMessage);
} else if (MyMessage == "Hello") {
Response.Write("True");
} else {
Response.Write("False");
}
if (!MyBool) {
Response.Write("False");
}
}
</script>
<html><body>
</body></html>
Use if statement with boolean type value (VB)
<%@ Page Language="VB" %>
<script runat="server">
sub Page_Load(Sender as object, e as eventargs)
dim MyMessage As String = "Hello"
dim MyBool As Boolean = True
if MyMessage = "Hello" then
Response.Write("True")
end if
if MyBool then
Response.Write("True")
end if
end sub
</script>
<html><body>
</body></html>
Use if statement with string type value (VB)
<%@ Page Language="VB" %>
<script runat="server">
sub Page_Load(Sender as object, e as eventargs)
dim MyMessage As String = "Hello"
dim MyBool As Boolean = True
if MyMessage = "Hello" then
Response.Write("True")
end if
if MyBool then
Response.Write("True")
end if
end sub
</script>
<html><body>
</body></html>