asp:DropDownList 的一些属性

asp:DropDownList 的一些属性使用 BorderStyle 属性为Web服务器控件指定边框样式。 使用一个 BorderStyle 枚举值设置此属性。 下表列出了可能的值。边框样式说明NotSet不设置边框样式。None无边框Dotted虚线边框。

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

使用 BorderStyle 属性为 Web 服务器控件指定边框样式。 使用一个 BorderStyle 枚举值设置此属性。 下表列出了可能的值。

边框样式

说明

NotSet

不设置边框样式。

None

无边框

Dotted

虚线边框。

Dashed

点划线边框。

Solid

实线边框。

Double

双实线边框。

Groove

用于凹陷边框外观的凹槽状边框。

Ridge

用于凸起边框外观的突起边框。

Inset

用于凹陷控件外观的内嵌边框。

Outset

用于凸起控件外观的外嵌边框。

 

<%@ Page language="c#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    private void Page_Load(object sender, System.EventArgs e)
    {
        // Determine whether this is the first time the page is loaded;
        // if so, load the drop-down lists with data.
        if (!Page.IsPostBack)
        {
            // Create a ListItemCollection and add names of colors.
            ListItemCollection colors = new ListItemCollection();
            colors.Add(Color.Black.Name);
            colors.Add(Color.Blue.Name);
            colors.Add(Color.Green.Name);
            colors.Add(Color.Orange.Name);
            colors.Add(Color.Purple.Name);
            colors.Add(Color.Red.Name);
            colors.Add(Color.White.Name);
            colors.Add(Color.Yellow.Name);
            // Bind the colors collection to the borderColorList.
            borderColorList.DataSource = colors;
            borderColorList.DataBind();

            // Create a ListItemCollection and the add names of 
            // the BorderStyle enumeration values.
            ListItemCollection styles = new ListItemCollection();

            foreach (string s in Enum.GetNames(typeof(BorderStyle)))
            {
                styles.Add(s);
            }

            // Bind the styles collection to the borderStyleList.
            borderStyleList.DataSource = styles;
            borderStyleList.DataBind();

            // Create a ListItemCollection and add width values
            // expressed in pixels (px).
            ListItemCollection widths = new ListItemCollection();

            for (int i = 0; i < 11; i++)
            {
                widths.Add(i.ToString() + "px");
            }

            // Bind the widths collection to the borderWidthList.
            borderWidthList.DataSource = widths;
            borderWidthList.DataBind();
        }

    }

    // This method handles the SelectedIndexChanged event for borderColorList.
    public void ChangeBorderColor(object sender, System.EventArgs e)
    {
        // Convert the color name string to an object of type Color, 
        // and set the Color as the new border color for Label1.
        Label1.BorderColor = Color.FromName(borderColorList.SelectedItem.Text);
    }

    // This method handles the selectedIndexChanged event for boderStyleList.
    public void ChangeBorderStyle(object sender, System.EventArgs e)
    {
        // Convert the style name string to a BorderStyle enumeration value,
        // and set the BorderStyle as the new border style for Label1.
        Label1.BorderStyle = (BorderStyle)Enum.Parse(typeof(BorderStyle),
                              borderStyleList.SelectedItem.Text);
    }

    // This method handles the SelectedIndexChanged event for borderWidthList.
    public void ChangeBorderWidth(object sender, System.EventArgs e)
    {
        // Convert the border width string to a object of type Unit,
        // and set the Unit as the new border width for Label1.
        Label1.BorderWidth = Unit.Parse(borderWidthList.SelectedItem.Text);
    }
    </script>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
    <title> Border Properties Example </title>
</head>

    <body>
        <form id="form1" runat="server">

            <h3> Border Properties Example </h3>

            <table border="0" cellpadding="6">
                <tr>
                    <td>
                        <asp:Label Runat="server" BorderColor="Black" 
                            BorderStyle="Solid" BorderWidth="4px" ID="Label1" 
                            Text="Border Properties Example" Height="75" 
                            Width="200"><center><br />Border Properties Example
                            </center></asp:Label>
                    </td>

                    <td>
                        <asp:DropDownList Runat="server" ID="borderColorList" 
                            OnSelectedIndexChanged="ChangeBorderColor" AutoPostBack="True" 
                            EnableViewState="True"></asp:DropDownList>
                        <br />
                        <br />
                        <asp:DropDownList Runat="server" ID="borderStyleList" 
                            OnSelectedIndexChanged="ChangeBorderStyle" AutoPostBack="True" 
                            EnableViewState="True"></asp:DropDownList>
                        <br />            
                        <br />
                        <asp:DropDownList Runat="server" ID="borderWidthList" 
                            OnSelectedIndexChanged="ChangeBorderWidth" AutoPostBack="True"
                            EnableViewState="True"></asp:DropDownList>
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/181059.html原文链接:https://javaforall.net

(0)
上一篇 2022年10月17日 上午10:46
下一篇 2022年10月17日 上午11:00


相关推荐

  • 项目复盘/总结模板

    项目复盘/总结模板复盘会议的安排、步骤及意义什么是复盘?为何要复盘?WHAT?复盘,是行动后的深刻反思和经验总结,是一个不断学习、总结、反思、提炼和持续提高的过程。复盘是企业文化、是行动学习、是提升组织智慧的重

    2022年8月3日
    9
  • C语言中的问号表达式

    C语言中的问号表达式这道题目中的 w

    2026年3月3日
    3
  • .NET软件工程师网络在线培训就业课程「建议收藏」

    .NET软件工程师网络在线培训就业课程「建议收藏」.NET软件工程师网络在线培训就业课程课程讲师:北风.NET专职讲师团队 课程分类:套餐适合人群:高级课时数量:2000课时用到技术:MVC5,EF6,BootStrap,HTML5,JqueryMobile,VS,.NET,ASP.NET 北风团队精心打造的42个经典案例,囊括了企业常见项目开发90%的典型应用 1、典型登录

    2022年7月19日
    20
  • MSAgent 详细解说(上)「建议收藏」

    MSAgent 详细解说(上)「建议收藏」转:http://www.blueidea.com/tech/web/2004/1643.asp 作者windy_sk 邮箱:windy_sk@126.com下面是原文:本文完全原创,所有参考都是msdn.microsoft.com/library/en-us/msagent/agentstartpage_7gdh.asp引子:本来两年前就打算写了,结果拖了这么长时间,近日看到有朋友问及…

    2022年4月19日
    53
  • java 实用 代码_java新手实用代码有哪些?java新手代码大全「建议收藏」

    java 实用 代码_java新手实用代码有哪些?java新手代码大全「建议收藏」对于java新手来说,积累一些实用的基础代码还是很有必要的,毕竟写代码是需要实践以及积累的,那么接下来,我们就来给大家分享一些java新手代码给大家参考!1.字符串有整型的相互转换Stringa=String.valueOf(2);//integertonumericstringinti=Integer.parseInt(a);//numericstringtoan…

    2022年6月21日
    31
  • SQL模糊查询语句(like)

    SQL模糊查询语句(like) 确定给定的字符串是否与指定的模式匹配。模式可以包含常规字符和通配符字符。模式匹配过程中,常规字符必须与字符串中指定的字符完全匹配。然而,可使用字符串的任意片段匹配通配符。与使用=和!=字符串比较运算符相比,使用通配符可使LIKE运算符更加灵活。如果任何参数都不属于字符串数据类型,MicrosoftSQLServer会将其转换成字符串数据类型(如果可能)。语法mat

    2022年5月26日
    176

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号