我需要制作用户评级系统,我正在使用ajax评级控件。我已经定义了它的所有css仍然无法正常工作。喜欢现在有5星评级,如果用户点击任何一颗星,直到那个星色应该改变,但在这里它不是那样工作。同样在我悬停鼠标的任何一颗星上,它显示工具提示1.下面是我的代码。
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ratings.aspx.vb" Inherits="ratings" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="stylesheet" type="text/css" href="/fonts/fontawesome/fontawesome.css" />
<style type="text/css">
.star:before {
color: #f00;
font-size:2em
}
.empty:before {
color: #ccc;
font-size:2em
}
.WaitingStar:before {
color: #ed2025;
font-size:2em
}
.FilledStar:before {
color: #ffcc00;
font-size:2em
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="sc1" runat="server"></asp:ToolkitScriptManager>
<div>
<asp:Rating ID="Rating2" runat="server" ClientIDMode="Static" StarCssClass="star fa fa-star" EmptyStarCssClass="empty fa fa-star" WaitingStarCssClass="WaitingStar fa fa-star" FilledStarCssClass="FilledStar fa fa-star" MaxRating="5" CurrentRating="1">
</asp:Rating>
</div>
</form>
</body>
</html>
在上面的屏幕截图中,您可以看到我的光标位于第3星,因此有色并没有变化,工具提示显示1而不是3.为了更好地理解,您也可以参考我上传的{{3}页} http://foxboxrewards.com/ratings.aspx
Web.config(出现错误时)
<trust level="Full" />
<customErrors mode="Off" />
<authentication mode="None"/>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" />
<machineKey validationKey="B4973B4FA7A0A4F212F7264B3D5AB728CC59827D255087B064E5546E9C4D6D02F9D59224FE6EB33716C21CE6D2ADD174B9B4AEEBEFDA22D860643EDABB71A423" decryptionKey="DC2B319841AEF51E81AFC4135BAF9A5C2B010DAB2C97F9983CFF8CA2146E61B0" validation="SHA1" decryption="AES" />
<pages validateRequest="false">
<namespaces>
<add namespace="System.Web.Optimization"/>
<add namespace="Microsoft.AspNet.Identity"/>
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt"/>
</controls>
</pages>
Web.config(工作)
<authentication mode="None"/>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<pages>
<namespaces>
<add namespace="System.Web.Optimization"/>
<add namespace="Microsoft.AspNet.Identity"/>
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt"/>
</controls>
</pages>
答案 0 :(得分:0)
我按照以下步骤使应用程序正常工作: -
1.安装ASP.NET AJAX Control Toolkit运行new installer from DevExpress.com:
2。接受许可协议,将为安装的每个受支持的Microsoft Visual Studio版本安装AJAX Control Toolkit
3。此工具箱中将提供此Ajax控件工具包。
4。这是我的.aspx页面
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SO.Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="Content/font-awesome.css" rel="stylesheet" />
<style type="text/css">
.star:before {
color: #f00;
font-size:2em
}
.empty:before {
color: #ccc;
font-size:2em
}
.WaitingStar:before {
color: #ed2025;
font-size:2em
}
.FilledStar:before {
color: #ffcc00;
font-size:2em
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<ajaxToolkit:Rating ID="Rating2" runat="server" ClientIDMode="Static"
StarCssClass="star fa fa-star" EmptyStarCssClass="empty fa fa-star"
WaitingStarCssClass="WaitingStar fa fa-star" FilledStarCssClass="FilledStar fa fa-star" MaxRating="5" CurrentRating="1">
</ajaxToolkit:Rating>
</div>
</form>
</body>
</html>
注意 - 我正在使用AJAX Extensions中的asp:ScriptManager标记。通常如果使用.NET Framework 4.0或更高版本,则使用asp:ScriptManager比使用ajaxToolkit更好:ToolkitScriptManager
当您拖放ajaxToolkit时:从工具箱中评分@Register指令会自动为您添加
当我按下ctrl + F5时一切正常