rating

Last post 01-14-2009 3:17 AM by Zhi-Qiang Ni - MSFT. 3 replies.

Sort Posts:

  • rating

    01-08-2009, 10:33 AM
    • Member
      434 point Member
    • ashkant
    • Member since 06-10-2008, 7:32 AM
    • Posts 277

    hi

     i use ajax rating for voting but i want to have for example every 10 vote as 1. so i wrote this code

    <cc1:Rating ID="Rating1" runat="server" Direction="RightToLeft" RatingDirection="RightToLeftBottomToTop"

    EmptyStarCssClass="emptyRatingStar" FilledStarCssClass="filledRatingStar"

    CurrentRating='<%# int.Parse(Eval("ItemNumber").ToString()) / 10 %>' MaxRating="150" StarCssClass="ratingStar" ReadOnly="true"

    WaitingStarCssClass="savedRatingStar">

    </cc1:Rating>

     

    it's ok. but  rating has something like tooltip. as the mouse go over it shows the current rating. i want show the real amount of ItemNumber. is it possible?

    i mean for example i have 3 stars but onmouse over it shows 30.

    what can i do?

     

    at least i dont wanna see that tooltip thing

     

    thanks

    Please remember to click “Mark as Answer” on the post that helps you
  • Re: rating

    01-12-2009, 4:40 AM
    Answer

    Hi ashkant,

    Please refer to my sample code: 

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="SoluTest_RatingControl._Default" %>
    
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <!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>
        <style type="text/css">
            /* Rating */
            .ratingStar
            {
                font-size: 0pt;
                width: 13px;
                height: 12px;
                margin: 0px;
                padding: 0px;
                cursor: pointer;
                display: block;
                background-repeat: no-repeat;
            }
            .filledRatingStar
            {
                background-image: url(Image/FilledStar.png);
            }
            .emptyRatingStar
            {
                background-image: url(Image/EmptyStar.png);
            }
            .savedRatingStar
            {
                background-image: url(Image/SavedStar.png);
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            <cc1:Rating ID="ThaiRating" runat="server" BehaviorID="RatingBehavior1" CurrentRating="2"
                MaxRating="5" StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar"
                FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar" Style="float: left;" />
        </div>
        </form>
    
        <script language="javascript" type="text/javascript">
    
        function pageLoad()
        {
            $find("RatingBehavior1").add_MouseOver(ratingOnMouseOver);
        }
        function ratingOnMouseOver(sender, eventArgs) {
            var elt = sender.get_element();
            //please modify this code as your wish, for example sender._currentRating*10
            $get(elt.id + "_A").title = sender._currentRating + " Stars";
        }
        </script>
    
    </body>
    </html>
    Have my suggestion helped?

    Best regards,

    Zhi-Qiang Ni

    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
  • Re: rating

    01-14-2009, 2:13 AM
    • Member
      434 point Member
    • ashkant
    • Member since 06-10-2008, 7:32 AM
    • Posts 277

     hi.thanks

    but i recieve this javascript error: Sys.InvalidOperationException: Two components with the same id 'RatingBehavior1' can't be added to the application.

    i use it in my ContentPlaceHolder1 in default.aspx page.

    Can u help on this error?

    Please remember to click “Mark as Answer” on the post that helps you
  • Re: rating

    01-14-2009, 3:17 AM
    Answer
    Hi ashkant,

    Every extender of the AjaxControlToolkit has a unique BehaviorId which is used to find its client behavior. To avoid the exception of duplicate BehaviorId, please remove this property. You can use this method to find all the RatingBehaviors.
            function pageLoad() {
    var currentBehavior = null;
    var allBehaviors = Sys.Application.getComponents();
    for (var loopIndex = 0; loopIndex < allBehaviors.length; loopIndex++) {
    currentBehavior = allBehaviors[loopIndex];
    if (currentBehavior.get_name() == "RatingBehavior") {
    currentBehavior.add_MouseOver(ratingOnMouseOver);
    }
    }
    }
    Have my code helped?

    Best regards,

    Zhi-Qiang Ni

    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
Page 1 of 1 (4 items)