第四章        网页计算器
1)前台页面设计:
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

 

 

 

 

 

 

 

2)预览效果:
3)后台代码编写:
 
try

        {

            double a = Convert.ToDouble(TextBox1.Text);

            double b = Convert.ToDouble(TextBox2.Text);

            if (DropDownList1.SelectedValue == "")

            {

                Label1.Text = Convert.ToString(a + b);

            }

            else if (DropDownList1.SelectedValue == "")

            {

                Label1.Text = Convert.ToString(a - b);

            }

            else if (DropDownList1.SelectedValue == "")

            {

                Label1.Text = Convert.ToString(a * b);

            }

            else if (DropDownList1.SelectedValue == "")

            {

                if (b != 0)

                {

 

                    Label1.Text = Convert.ToString(a / b);

                }

                else

                {

                    Label1.Text = "不能除以0";

                }

            }

        }

        catch

        {

            Label1.Text = "请输入数字";

        }

 

4)验证成功!