asp.net 4.5 exercise~test4-9

webform1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test4_9.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="您的最高学历:"></asp:Label>
        <br />
        <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" RepeatDirection="Horizontal">
            <asp:ListItem>小学</asp:ListItem>
            <asp:ListItem>初中</asp:ListItem>
            <asp:ListItem>高中</asp:ListItem>
            <asp:ListItem>大学专科</asp:ListItem>
            <asp:ListItem>大学本科</asp:ListItem>
            <asp:ListItem>硕士研究生</asp:ListItem>
            <asp:ListItem>博士研究生</asp:ListItem>
        </asp:RadioButtonList>
        <br />
        <asp:Button ID="btn_submit" runat="server" Text="提交" OnClick="btn_submit_Click" />
        <br />
        <asp:Label ID="lbl_tips" runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>

webform1.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace test4_9
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_submit_Click(object sender, EventArgs e)
        {
            string result = RadioButtonList1.Text;
            lbl_tips.Text = Label1.Text + result;
        }
    }
}

 

Guess you like

Origin blog.csdn.net/modern358/article/details/114259744