我今天早些时候已经下载了ajaxtoolkit,并且我已尝试使用Rating对象做一些非常基本的事情,但是,OnChanged事件根本没有触发 - 有人可以向我解释我做错了什么?
守则:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.Star {
background-image: url(images/Star.png);
height: 30px;
width: 30px;
background-repeat: no-repeat;
}
.FilledStar {
background-image: url(images/FilledStar.png);
height: 30px;
width: 30px;
background-repeat: no-repeat;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Your Current Rating is...."></asp:Label>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<ajaxToolkit:Rating ID="Rating1" OnChanged="Rating1_Changed" AutoPostBack="true" runat="server"
StarCssClass="Star" EmptyStarCssClass="Star"
FilledStarCssClass="FilledStar" WaitingStarCssClass="Star">
</ajaxToolkit:Rating>
</div>
</form>
</body>
</html>
背后的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Rating1_Changed(object sender, AjaxControlToolkit.RatingEventArgs e)
{
Label1.Text = Rating1.CurrentRating.ToString();
}
}
这是我在这里发表的第一篇文章,所以如果我做错了,我很抱歉:$ 谢谢!
答案 0 :(得分:0)
触发点击事件,而不是更改事件。 肯定会起作用