📄 tio-if.aspx
字号:
<%@ Page Language="C#" %>
<script runat="server">
void Page_Load()
{
int theNumber, theGuess;
Random objRandom;
objRandom = new Random();
theNumber = Convert.ToInt32(objRandom.Next(5)) + 1;
if (Page.IsPostBack)
{
theGuess = Convert.ToInt32(Guess.SelectedItem.Value);
if (theGuess > theNumber)
{
message.Text = "<BR><BR>Guess was too high<BR>Try again - it was "
+ theNumber;
}
if (theGuess < theNumber)
{
message.Text = "<BR><BR>Guess was too low<BR>Try again - it was " + theNumber;
}
if (theGuess == theNumber)
{
message.Text = "<BR><BR>Guess was correct!";
}
} //end if (Page.IsPostBack)
} //end Page_Load()
</script>
<html>
<head>
<title>IF THEN example - solution 1</title>
</head>
<body>
<form runat="server">
What number am I thinking of?
<asp:dropdownlist id="Guess" runat="server">
<asp:listitem>1</asp:listitem>
<asp:listitem>2</asp:listitem>
<asp:listitem>3</asp:listitem>
<asp:listitem>4</asp:listitem>
<asp:listitem>5</asp:listitem>
</asp:dropdownlist>
<br />
<br />
<input type="submit" value="Submit guess" />
<asp:label id="message" runat="server"></asp:label>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -