<%@ Page Language="c#" runat="server" %>
<script runat="server">
void Page_Load()
{
pi.Text = Math.PI.ToString();
exp.Text = Math.E.ToString();
}
void Update(object sender, EventArgs e)
{
try
{
double dblInput = Convert.ToDouble(input.Text);
sqrt_input.Text = dblInput.ToString();
sqrt_result.Text = Math.Sqrt(dblInput).ToString();
abs_input.Text = dblInput.ToString();
abs_result.Text = Math.Abs(dblInput).ToString();
log_input.Text = dblInput.ToString();
log_result.Text = Math.Log10(dblInput).ToString();
} catch {
sqrt_result.Text = "";
abs_result.Text = "";
log_result.Text = "";
errormessage.Text = "Error occurred in input";
}
}
</script>
<html>
<head>
</head>
<body>
<hr />
Pi = <asp:Label id="pi" runat="server"></asp:Label>
<br />
Exponential Constant = <asp:Label id="exp" runat="server"></asp:Label>
<hr />
<form runat="server">
Input =
<asp:textbox id="input" runat="server"></asp:textbox>
<asp:button id="Button1" onclick="Update" runat="server" text="Submit"></asp:button>
</form>
<hr />
Square root of <asp:Label id="sqrt_input" runat="server"></asp:Label>= <asp:Label id="sqrt_result" runat="server"></asp:Label>
<br />
Absolute Value of <asp:Label id="abs_input" runat="server"></asp:Label>= <asp:Label id="abs_result" runat="server"></asp:Label>
<br />
Logarithm of <asp:Label id="log_input" runat="server"></asp:Label>= <asp:Label id="log_result" runat="server"></asp:Label>
<br />
<asp:Label id="errormessage" runat="server"></asp:Label>
<br />
</body>
</html>
本文地址:http://com.8s8s.com/it/it7211.htm