<script runat="server" language="C#"> protected void Page_Load(object o, EventArgs e) { if(IsPostBack) { Page.DataBind(); } } protected double CalculateFactorial(int input) { double result = 1; for(;input > 0; input--) { result *= input; } return result; } </script> <form runat="server"> Databind the result of a method call. <asp:Textbox runat="server" id="theInput" /><br/> <asp:RequiredFieldValidator runat="server" ControlToValidate="theInput" ErrorMessage="input is required" /> <asp:RangeValidator runat="server" ControlToValidate="theInput" ErrorMessage="input must be >= 0 and < 20" Type="integer" MinimumValue="0" MaximumValue="20" /><br/> <asp:Button runat="server" type="submit" Text="Calculate Factorial" /><br/> The result is: <b><%# CalculateFactorial(Int32.Parse(theInput.Text)).ToString() %></b> </form>