weixin_46878047 2020-05-17 09:21 采纳率: 0%
浏览 177
已采纳

急求大佬帮助!!制作一个asp.net页面!!

要求:在页面中有两个文本框,分别输入两个数,然后给用户提供加减乘除四种运算选项。并能根据用户的选择,在页面中相应运算结果信息。得用到button,textbox等控件!!谢谢!!!

  • 写回答

1条回答 默认 最新

  • threenewbee 2020-05-17 09:31
    关注
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace Q1072616
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                if (DropDownList1.SelectedValue == "+")
                {
                    Label1.Text = (double.Parse(TextBox1.Text) + double.Parse(TextBox2.Text)).ToString();
                }
                else if (DropDownList1.SelectedValue == "-")
                {
                    Label1.Text = (double.Parse(TextBox1.Text) - double.Parse(TextBox2.Text)).ToString();
                }
                else if (DropDownList1.SelectedValue == "*")
                {
                    Label1.Text = (double.Parse(TextBox1.Text) * double.Parse(TextBox2.Text)).ToString();
                }
                else if (DropDownList1.SelectedValue == "/")
                {
                    Label1.Text = (double.Parse(TextBox1.Text) / double.Parse(TextBox2.Text)).ToString();
                }
            }
        }
    }
    
    
    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
        CodeBehind="Default.aspx.cs" Inherits="Q1072616._Default" %>
    
    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    </asp:Content>
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <%--    <h2>
            Welcome to ASP.NET!
        </h2>
        <p>
            To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
        </p>
        <p>
            You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"
                title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
        </p>--%>
        <h2>
            计算器
        </h2>
        <p>
            计算:
    
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:DropDownList ID="DropDownList1" runat="server">
                <asp:ListItem Selected="True">+</asp:ListItem>
                <asp:ListItem>-</asp:ListItem>
                <asp:ListItem>*</asp:ListItem>
                <asp:ListItem>/</asp:ListItem>
            </asp:DropDownList>
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
        </p>
        <p>
            结果:
    
    
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    
        </p>
    </asp:Content>
    
    

    图片说明

    问题解决的话,请点下采纳

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题