Rating control - how to start the code behind?

Last post 02-05-2008 11:01 AM by Jonathan Shen – MSFT. 1 replies.

Sort Posts:

  • Rating control - how to start the code behind?

    01-31-2008, 2:27 PM
    • Member
      324 point Member
    • Grzesiek23
    • Member since 12-23-2005, 5:52 PM
    • Posts 248

    So I have Rating control on my site.

    I want to start up the code after user's rating. Now I'm getting redirect to old url + "#".

     

    Thanks.
     

  • Re: Rating control - how to start the code behind?

    02-05-2008, 11:01 AM
    Answer

    Hi Grzesiek23,

    Grzesiek23:
    I want to start up the code after user's rating. Now I'm getting redirect to old url + "#".

    Your description is not clear enough.Based on my experience, I assume that you want to get the return words on client when Changed event is fired or you want to operate on server side.  Here is the a sample. Please wholly copy my sample to your project and have a test.   For more usages, you can find two pretty sample inside the AJAX Control Toolkit source code.

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
        protected void Rating1_Changed(object sender, RatingEventArgs e)
        {
            e.CallbackResult = "Hello, world!";
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
        <style type="text/css">
            .ratingStar {
                font-size: 0pt;
                width: 13px;
                height: 12px;
                margin: 0px;
                padding: 0px;
                cursor: pointer;
                display: block;
                background-repeat: no-repeat;
            }
    
            .filledRatingStar {
                background-image: url(../pic/FilledStar.png);
    
            }
    
            .emptyRatingStar {
                background-image: url(../pic/EmptyStar.png);
            }
    
            .savedRatingStar {
                background-image: url(../pic/SavedStar.png);
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
    
            <ajaxToolkit:Rating ID="Rating1" BehaviorID="RatingBehavior1" runat="server" CurrentRating="5"
                MaxRating="10"  StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar"
                FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar" Tag="99"
                OnChanged="Rating1_Changed" >
            </ajaxToolkit:Rating>
    
    
            <script type="text/javascript" language="javascript">
            function pageLoad(){
                $find("RatingBehavior1").add_EndClientCallback(onEndClientCallBack);
            }
            function onEndClientCallBack(sender, eventArgs){
                 alert(eventArgs.get_CallbackResult())
            }
            </script>
    
        </form>
    </body>
    </html>
    If I have misunderstood you, please feel free to let me know.

    Best regards,

    Jonathan

    Jonathan Shen
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (2 items)