国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Web用戶控件開發--星型評分控件

2019-11-17 02:48:02
字體:
來源:轉載
供稿:網友

Web用戶控件開發--星型評分控件

本文中分享一個實現簡單,使用方便的星型評分控件。

一:貼幾張測試圖片先:

image

image

image

二、星型評分控件的實現:

RatingBar.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RatingBar.ascx.cs" Inherits="UserControls.Controls.RatingBar" %>
<style type="text/CSS">
        .rating {
            float:left;
        }
        .rating:not(:checked) > input {
            position:absolute;
            top:-9999px;
            clip:rect(0,0,0,0);
        }
        .rating:not(:checked) > label {
            float:right;
            width:1em;
            padding:0 .1em;
            overflow:hidden;
            white-space:nowrap;
            cursor:pointer;
            font-size:150%;
            line-height:1.2;
            color:#ddd;
            text-shadow:1px 1px #bbb, 2px 2px #666, .1em .1em .2em rgba(0,0,0,.5);
        }
        .rating:not(:checked) > label:before {
            content: '★ ';
        }
        .rating > input:checked ~ label {
            color: #f70;
            text-shadow:1px 1px #c60, 2px 2px #940, .1em .1em .2em rgba(0,0,0,.5);
        }
        .rating:not(:checked) > label:hover,
        .rating:not(:checked) > label:hover ~ label {
            color: gold;
            text-shadow:1px 1px goldenrod, 2px 2px #B57340, .1em .1em .2em rgba(0,0,0,.5);
        }
        .rating > input:checked + label:hover,
        .rating > input:checked + label:hover ~ label,
        .rating > input:checked ~ label:hover,
        .rating > input:checked ~ label:hover ~ label,
        .rating > label:hover ~ input:checked ~ label {
            color: #ea0;
            text-shadow:1px 1px goldenrod, 2px 2px #B57340, .1em .1em .2em rgba(0,0,0,.5);
        }
        .rating > label:active {
            position:relative;
            top:2px;
            left:2px;
        }
    </style>
<span class="rating">
    <input type="radio" id="star5" name="rating" value="5" runat="server" /><label for="<%=this.ClientID + "_star5"%>"
        title="5分">5 stars</label>
    <input type="radio" id="star4" name="rating" value="4" runat="server" /><label for="<%=this.ClientID + "_star4"%>"
        title="4分">4 stars</label>
    <input type="radio" id="star3" name="rating" value="3" runat="server" /><label for="<%=this.ClientID + "_star3"%>"
        title="3分">3 stars</label>
    <input type="radio" id="star2" name="rating" value="2" runat="server" /><label for="<%=this.ClientID + "_star2"%>"
        title="2分">2 stars</label>
    <input type="radio" id="star1" name="rating" value="1" runat="server" /><label for="<%=this.ClientID + "_star1"%>"
        title="1分">1 star</label>
</span>

RatingBar.ascx.cs:

using System;
namespace UserControls.Controls
{
    public partial class RatingBar : System.Web.UI.UserControl
    {
        PRotected void Page_Load(object sender, EventArgs e)
        {
            SyncInterfaceByReadOnlyProperties();
        }
        public Grade Value
        {
            get
            {
                if (star5.Checked)
                {
                    return Grade.Five;
                }
                else if (star4.Checked)
                {
                    return Grade.Four;
                }
                else if (star3.Checked)
                {
                    return Grade.Three;
                }
                else if (star2.Checked)
                {
                    return Grade.Two;
                }
                else if (star1.Checked)
                {
                    return Grade.One;
                }
                else
                {
                    return Grade.Zero;
                }
            }
            set
            {
                star5.Checked = false;
                star4.Checked = false;
                star3.Checked = false;
                star2.Checked = false;
                star1.Checked = false;
                switch (value)
                {
                    case Grade.Five:
                        star5.Checked = true;
                        break;
                    case Grade.Four:
                        star4.Checked = true;
                        break;
                    case Grade.Three:
                        star3.Checked = true;
                        break;
                    case Grade.Two:
                        star2.Checked = true;
                        break;
                    case Grade.One:
                        star1.Checked = true;
                        br
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 清涧县| 仪陇县| 闽清县| 荔波县| 高安市| 古蔺县| 大厂| 伊宁市| 马边| 柞水县| 霞浦县| 鄂伦春自治旗| 固镇县| 囊谦县| 安平县| 怀来县| 手机| 敖汉旗| 遵义市| 临邑县| 蛟河市| 筠连县| 保定市| 攀枝花市| 潍坊市| 江川县| 乐亭县| 乌拉特前旗| 甘孜| 衡南县| 琼结县| 伊宁市| 舞钢市| 武平县| 平顺县| 墨竹工卡县| 萍乡市| 密山市| 沾化县| 津市市| 长武县|