• RatingOnChangedEvent.aspx

  1. <%@ Page Language="C#" AutoEventWireup="true" %>  
  2.   
  3. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>  
  4.   
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  6. <script runat="server">  
  7.     protected void Rating1_Changed(object sender, EventArgs e)  
  8.     {  
  9.         int ratingValue = Rating1.CurrentRating;  
  10.         if (ratingValue <= 3)  
  11.         {  
  12.             Label1.ForeColor = System.Drawing.Color.Red;  
  13.         }  
  14.         else  
  15.         {  
  16.             Label1.ForeColor = System.Drawing.Color.Green;  
  17.         }  
  18.         Label1.Text = "You Rated: " + ratingValue;  
  19.     }  
  20. </script>  
  21.   
  22. <html xmlns="http://www.w3.org/1999/xhtml">  
  23. <head id="Head1" runat="server">  
  24.     <title>Ajax Rating - How to use OnChanged event in asp.net Rating</title>  
  25.     <style type="text/css">  
  26.         .StarCss {   
  27.             background-image: url(/Image/star.png);  
  28.             height:24px;  
  29.             width:24px;  
  30.         }  
  31.         .FilledStarCss {  
  32.             background-image: url(/Image/filledstar.png);  
  33.             height:24px;  
  34.             width:24px;  
  35.         }  
  36.         .EmptyStarCss {  
  37.             background-image: url(/Image/star.png);  
  38.             height:24px;  
  39.             width:24px;  
  40.         }  
  41.         .WaitingStarCss {  
  42.             background-image: url(/Image/waitingstar.png);  
  43.             height:24px;  
  44.             width:24px;  
  45.         }  
  46.     </style>  
  47.   
  48. </head>  
  49. <body>  
  50.     <form id="form1" runat="server">  
  51.     <div>  
  52.         <h2 style="color:DarkBlue; font-style:italic;">  
  53.             ASP.NET Ajax Rating - How to use OnChanged  
  54.             <br /> event in asp.net Rating  
  55.         </h2>  
  56.         <hr width="500" align="left" color="LightBlue" />  
  57.         <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">  
  58.         </asp:ToolkitScriptManager>  
  59.         <table border="0" cellpadding="4" cellspacing="4">  
  60.             <tr>  
  61.                 <td>  
  62.                     <asp:Image   
  63.                         ID="Image1"  
  64.                         runat="server"  
  65.                         ImageUrl="~/Image/RedBird.jpg"  
  66.                         Height="250"  
  67.                         />  
  68.                 </td>  
  69.                 <td>  
  70.                     <asp:Label   
  71.                         ID="Label1"  
  72.                         runat="server"  
  73.                         Font-Size="X-Large"  
  74.                         Font-Italic="true"  
  75.                         Font-Names="Comic Sans MS"  
  76.                         >  
  77.                     </asp:Label>  
  78.                     <br /><br />  
  79.                     <asp:Label   
  80.                         ID="Label2"  
  81.                         runat="server"  
  82.                         ForeColor="SandyBrown"  
  83.                         Font-Size="Large"  
  84.                         Text="Rate this image"  
  85.                         >  
  86.                     </asp:Label>  
  87.                     <br />  
  88.                     <asp:Rating   
  89.                         ID="Rating1"  
  90.                         runat="server"  
  91.                         StarCssClass="StarCss"  
  92.                         FilledStarCssClass="FilledStarCss"  
  93.                         EmptyStarCssClass="EmptyStarCss"  
  94.                         WaitingStarCssClass="WaitingStarCss"  
  95.                         AutoPostBack="true"  
  96.                         OnChanged="Rating1_Changed"  
  97.                         >  
  98.                     </asp:Rating>  
  99.                 </td>  
  100.             </tr>  
  101.         </table>  
  102.     </div>  
  103.     </form>  
  104. </body>  
  105. </html>  








2 comments:

dhruv said...

wow, you are doing a good work, bro

Unknown said...

thankx bro

Post a Comment