I want to have a specific text if the typed age is below 12 years old. I thought of some covert to int, in some kind of way. But i can’t figure out how. Can someone help me out?
This is what i have:
<asp:TextBox ID="txtAge" runat="server" />
<br />
<asp:Button ID="btnSend" runat="server" Text="Send" onclick="btnSend_Click" />
<br />
<asp:Literal ID="litResult" runat="server" />
This is my code-behind:
protected void btnSend_Click(object sender, EventArgs e)
{
if (txtAge.Text <= 12)
{
litResult.Text = "You are a child";
}
}
The
Textproperty of aTextBoxis a string, so you need to convert the age to anint.