Thanks for your reply, Integrasol . Correct me if I am wrong, the above link is about displaying a message to user, not allowing the user to rate again (only one attempt for each user for rating) and saving results to a database file!!
I tried the link but it is giving me some errors. I don’t know whether I am following the steps correctly or not. This is what my html (.aspx) looks before changes.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>rating Control Demo</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" />
<div>
<div>
<div>Rating Demonstration </div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="float: left; width:170;">Rate My Site?</div>
<cc1:Rating ID="LikeRating" runat="server"
CurrentRating="0"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar" FilledStarCssClass="filledRatingStar"
EmptyStarCssClass="emptyRatingStar"
OnChanged="LikeRating_Changed"
style="float: left;">
</cc1:Rating>
<b />
<div style="clear:left;">
<br />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</form>
</body>
</html>
This is how it looks like after changes(showing only the body)
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" />
<div>
<div>
<div>Rating Demonstration </div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="float: left; width:170;">Rate My Site?</div>
<cc1:Rating ID="LikeRating" runat="server"
CurrentRating="0"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar" BehaviorID="RatingBehavior1"
FilledStarCssClass="filledRatingStar"
EmptyStarCssClass="emptyRatingStar"
OnChanged="LikeRating_Changed"
style="float: left;">
</cc1:Rating>
<script type="text/javascript">
Sys.Application.add_load(function() {
$find("RatingBehavior1").add_EndClientCallback( function(sender, e) {var responseTag = $get('lblResponse'); responseTag.innerHTML = e.get_Callback
</script>
<span id="lblResponse"></span>
<b />
<div style="clear:left;">
<br />
<asp:Label ID="LabelResponse" runat="server" Text="[ No response provioded yet.]"></asp:Label>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</form>
</body>
Coming to the aspx.cs file i.e. the callbackresult at client side…I am not able to understand the code. It seems like its converting the message which is of integer type to string and displaying it! So, just used a string to display the message
protected void LikeRating_Changed(object sender, AjaxControlToolkit.RatingEventArgs e)
{
Thread.Sleep(500);
string message = "thanks";
e.CallbackResult = message;
}
But nothing works. What am I doing wrong?
Thanks for your help.