如何在新标签的下拉列表中获取选择值(标签是根据选定的值自动创建的) [英] How to fetch select values in dropdownlist in new Label(label is automatic create according to selected vale)

查看:77
本文介绍了如何在新标签的下拉列表中获取选择值(标签是根据选定的值自动创建的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在网页上的标签中获取值。在dropdwonlist.And Label中选择的值将根据值自动创建一个再见。

how to fetch value in label on web page.Values selected in the dropdwonlist.And Label are automatic create one bye one according to value.

推荐答案

研究示例并适应:

aspx页面:

Study the example and adapt:
the aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default32.aspx.cs" Inherits="Default32" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:DropDownList id="drop1" runat="server"

            onselectedindexchanged="drop1_SelectedIndexChanged" AutoPostBack="true">
            <asp:ListItem Value="value1">Item 1</asp:ListItem>
            <asp:ListItem Value="value2">Item 2</asp:ListItem>
            <asp:ListItem Value="value3">Item 3</asp:ListItem>
            <asp:ListItem Value="value4">Item 5</asp:ListItem>
            <asp:ListItem Value="value5">Item 6</asp:ListItem>
    </asp:DropDownList>
        <div id="myDiv" runat="server">
        </div>
    </div>
    </form>
</body>
</html>



背后的代码:


the code behind:

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

public partial class Default32 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void drop1_SelectedIndexChanged(object sender, EventArgs e)
    {
        myDiv.InnerHtml = myDiv.InnerHtml + "<br />" + drop1.SelectedValue;
    }
}


这篇关于如何在新标签的下拉列表中获取选择值(标签是根据选定的值自动创建的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆