asp.net 4.5 练习~test5-2
发布日期:2021-05-06 21:15:34 浏览次数:15 分类:原创文章

本文共 1976 字,大约阅读时间需要 6 分钟。

webform1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test5_2.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>        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" Width="240px">            <asp:ListItem Value="0">请任选一项</asp:ListItem>            <asp:ListItem Value="1">我的出生地</asp:ListItem>            <asp:ListItem Value="2">我母亲的名字</asp:ListItem>            <asp:ListItem Value="3">我父亲的名字</asp:ListItem>        </asp:DropDownList>        <br />        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>        <asp:TextBox ID="TextBox1" runat="server" Width="99px"></asp:TextBox>    </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 test5_2{    public partial class WebForm1 : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {            Label2.Text = "答案:";        }        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)        {            switch (DropDownList1.SelectedValue)            {                 case "1":                    Label2.Text = DropDownList1.Items[DropDownList1.SelectedIndex].Text+":";                    break;                case "2":                    Label2.Text = DropDownList1.Items[DropDownList1.SelectedIndex].Text + ":";                    break;                case "3":                    Label2.Text = DropDownList1.Items[DropDownList1.SelectedIndex].Text + ":";                    break;            }        }    }}

 

上一篇:asp.net 4.5 练习~test5-3
下一篇:asp.net 4.5 练习~test5-1

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2025年03月20日 02时09分12秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章