[2008/07/16]code
Rating Control using custom web control

MyVote.cs
rating.aspx
rating.aspx.cs
MyVote.cs
using System;
using System.Data;
using System.Configuration;
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;
/// <summary>
/// Summary description for Class1
/// </summary>
///
namespace MyVote
{
public class Voting : WebControl,INamingContainer
{
private string voteNumber;
private int iStarCount = 3;
private string overImageUrl;
private string outImageUrl;
private ImageButton im;
public event EventHandler Click;
public string VoteCount
{
get { return voteNumber; }
set { voteNumber = value; }
}
public string MouseOver_ImagePath
{
get { return overImageUrl; }
set { overImageUrl = value; }
}
public string MouseOut_ImagePath
{
get { return outImageUrl; }
set { outImageUrl = value; }
}
public int StarCount
{
get { return iStarCount; }
set { iStarCount = value; }
}
protected override bool OnBubbleEvent(object source, EventArgs e)
{
if (e is CommandEventArgs)
{
CommandEventArgs ce = (CommandEventArgs)e;
if (ce.CommandName == "Click")
{
VoteCount = ce.CommandArgument.ToString();
OnClick(ce);
}
}
return true;
}
protected virtual void OnClick(EventArgs e)
{
if (Click != null)
{
Click(this, e);
}
}
protected override void CreateChildControls()
{
for (int i = 1; i < StarCount + 1; i++)
{
im = new ImageButton();
im.ImageUrl = MouseOut_ImagePath ;
im.Attributes.Add("onmouseover", "this.src='" + MouseOver_ImagePath + "';");
im.Attributes.Add("onmouseout", "this.src='" + MouseOut_ImagePath + "';");
im.AlternateText = i.ToString();
im.ID = "but" + i.ToString();
im.CommandName = "Click";
im.CommandArgument = i.ToString();
Controls.Add(im);
}
}
}
}
rating.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="rating.aspx.cs" Inherits="rating" %>
<%@ Register TagPrefix="MyBar" Namespace="MyVote" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<br />
<strong><span style="font-size: 14pt; font-family: Verdana">Rating Control</span></strong><br />
<br />
<br />
<MyBar:voting runat=server id="RatingCtrl" width="100px" StarCount="5" MouseOut_ImagePath="star.jpg" MouseOver_ImagePath="starover.jpg" OnClick="RatingCtrl_Click" >
</MyBar:voting>
<div id="kd">
<br />
<br />
<br />
<asp:Label ID="lbllabel" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
rating.aspx.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;
public partial class rating : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RatingCtrl_Click(object sender, EventArgs e)
{
lbllabel.Text ="Your Rate this : "+ RatingCtrl.VoteCount+ " Star";
}
}
...全文
相关推荐
《Visual Basic 2008入门经典》源代码
**Chapter 16 Code.zip**:这一章可能涉及到VB2008的高级主题,如类和对象的使用、事件驱动编程或者多线程等。这些代码实例将帮助理解面向对象编程的关键概念。3.
07 - libvpx 技术全景:WebM VP8/VP9 视频编解码引擎完整解析
本文深入解析了开源视频编解码库libvpx的技术架构与实现细节。作为WebM项目的核心组件,libvpx提供VP8和VP9两种视频标准的完整实现,广泛应用于Web视频、实时通信等领域。文章从项目概况、架构设计、编码流程等多个维度展开分析,重点对比了VP8与VP9在编码单元、变换大小、参考帧等关键技术指标上的差异,详细阐述了libvpx的分层架构设计,包括公共API层、编解码实现层和DSP优化层,并图解说明了视频编码的完整处理流程。该库支持多平台SIMD优化,通过RTCD机制动态选择最优实现
Microsoft.Press==Visual.Basic.2008.Step.by.Step_Code
**chap16** - 最后,这章可能介绍了文件I/O操作,如读写文本文件或二进制文件,这对于数据持久化和日志记录等任务是必不可少的。
QR code 生成二维码 demo (VS2008-C++)
本项目是基于Visual Studio 2008的C++实现的一个二维码生成示例,为开发者提供了一种实用的工具。
linphone vs2008
Download From code.google.com.Not my personal worklinphone 3.4.x VS2008 编译项目及源码1,适用于开发Windows 版SIP 软


