自定义控件之星级评价控件
来源:互联网 发布:淘宝自己的店铺在哪里 编辑:程序博客网 时间:2024/04/29 08:03
最近做了一个评价的页面。上面是星星的 挺可爱 放到我的知识库里。调试了好久才成功 星星里面都是汗水呀。
1.Star.ascx
<%@ Control Language="C#" AutoEventWireup="true" Codebehind="Star.ascx.cs"
Inherits="**********" %>
<script type="text/javascript" language="javascript">
function <%=this.ClientID %>_mouseOver(image){
var id = image.id.substr(image.id.length-1,1);
var type = image.id.substr(image.id.length-2,1);
if(id != 0)
{
for(i=id;i>0;i--)
{
var image1 = document.getElementById(image.id.substr(0, image.id.length-2)+ type + i);
image1.src = "../yes.JPG";
}
}
}
function <%=this.ClientID %>_mouseOut(image){
var type = image.id.substr(image.id.length-2,1);
var hid1 = '<%=hidScore.ClientID %>';
var hid2 = document.getElementById(hid1);
var selectID = hid2.value;
if(hid2.value == "")
{
selectID = 0;
}
for(i=1;i<6;i++)
{
var image1 = document.getElementById(image.id.substr(0, image.id.length-2)+ type + i)
if( i <= selectID)
{
image1.src = "../yes.JPG";
}
else
{
image1.src = "../no.JPG";
}
}
}
function <%=this.ClientID %>_onClick(image)
{
var id = image.id.substr(image.id.length-1,1);
var type = image.id.substr(image.id.length-2,1);
if(id != 0)
{
var hid1 = '<%=hidScore.ClientID %>';
var hid2 = document.getElementById(hid1);
hid2.value = id;
for(i=1;i<6;i++)
{
var image1 = document.getElementById(image.id.substr(0, image.id.length-2)+ type + i);
if (i <= id) {
image1.src = "../yes.JPG";
}
else {
image1.src = "../no.JPG";
}
}
<%=this.ClientID%>_clickFlg = true;
}
}
</script>
<div>
<asp:Image ID="S1" ImageUrl="../no.JPG" runat="server" />
<asp:Image ID="S2" ImageUrl="../no.JPG" runat="server" />
<asp:Image ID="S3" ImageUrl="../no.JPG" runat="server" />
<asp:Image ID="S4" ImageUrl="../no.JPG" runat="server" />
<asp:Image ID="S5" ImageUrl="../no.JPG" runat="server" />
<asp:HiddenField ID="hidScore" Value="" runat="server" />
</div>
2.CommentStar.ascx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace ********{
public partial class Star : System.Web.UI.UserControl
{
public string Score
{
get { return this.hidScore.Value; }
set { this.hidScore.Value = value.ToString(); }
}
protected void Page_Load(object sender, EventArgs e)
{
S1.Attributes.Add("onmouseover", this.ClientID + "_mouseOver(this)");
S1.Attributes.Add("onmouseout", this.ClientID + "_mouseOut(this)");
S1.Attributes.Add("onclick", this.ClientID + "_onClick(this)");
S2.Attributes.Add("onmouseover", this.ClientID + "_mouseOver(this)");
S2.Attributes.Add("onmouseout", this.ClientID + "_mouseOut(this)");
S2.Attributes.Add("onclick", this.ClientID + "_onClick(this)");
S3.Attributes.Add("onmouseover", this.ClientID + "_mouseOver(this)");
S3.Attributes.Add("onmouseout", this.ClientID + "_mouseOut(this)");
S3.Attributes.Add("onclick", this.ClientID + "_onClick(this)");
S4.Attributes.Add("onmouseover", this.ClientID + "_mouseOver(this)");
S4.Attributes.Add("onmouseout", this.ClientID + "_mouseOut(this)");
S4.Attributes.Add("onclick", this.ClientID + "_onClick(this)");
S5.Attributes.Add("onmouseover", this.ClientID + "_mouseOver(this)");
S5.Attributes.Add("onmouseout", this.ClientID + "_mouseOut(this)");
S5.Attributes.Add("onclick", this.ClientID + "_onClick(this)");
}
}
}
3.调用的画面:
a.要先注册一下:
<%@ Register Src="~/Star.ascx" TagPrefix="c1" TagName="Star" %>
b.使用的地方:
<c1:Star ID="csServiceRating" runat="server" />
4.备注:
yes.JPG是
no.JPG是
- 自定义控件之星级评价控件
- Android自定义简单控件--星级评价
- 写星级评价的控件,以及自定义的lable控件
- ios自定义星级控件
- Android 自定义星级评分控件
- android 自定义星级评分控件
- Android控件之RatingBar(类似淘宝实现滑动星级评价效果)
- Android自定义控件--评分星级View
- android自定义控件(星级评分)
- ASP.NET自定义控件 简单的星级控件
- ASP.NET自定义控件 第一天 简单的星级控件
- ASP.NET评分自定义控件 星级评分控件
- 安卓星级控件
- 星级评定控件RatingBar
- 【Android自定义View实战】之自定义评价打分控件RatingBar,可以自定义星星大小和间距
- 【Android自定义View实战】之自定义评价打分控件RatingBar,可以自定义星星大小和间距
- Android自定义View之自定义评价打分控件RatingBar实现自定义星星大小和间距
- 【Android自定义View实战】之自定义评价打分控件RatingBar,可以自定义星星大小和间距
- ThinkPHP中RBAC数据库详解
- 新产品开发流程
- 解决安装 maven for eclipse插件后,eclipse启动时警告
- 自己对XML中XSL的学习笔记的源代码
- 快速创建BIM业务单元
- 自定义控件之星级评价控件
- C#中DBNull.Value和Null的用法和区别
- 数据结构之一(引论及最大子序列和问题)
- 用PMD自动执行Java代码静态分析
- Windows SDK与Platform SDK的区别
- Android SDK 1.5中文版 (Application基础—2)
- 版本控制软件Visual Source safe使用小结
- S3C2410的linux下DMA驱动程序开发
- TCP三次握手