- RatingOnChangedEvent.aspx
- <%@ Page Language="C#" AutoEventWireup="true" %>
- <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
- <!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, EventArgs e)
- {
- int ratingValue = Rating1.CurrentRating;
- if (ratingValue <= 3)
- {
- Label1.ForeColor = System.Drawing.Color.Red;
- }
- else
- {
- Label1.ForeColor = System.Drawing.Color.Green;
- }
- Label1.Text = "You Rated: " + ratingValue;
- }
- </script>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head id="Head1" runat="server">
- <title>Ajax Rating - How to use OnChanged event in asp.net Rating</title>
- <style type="text/css">
- .StarCss {
- background-image: url(/Image/star.png);
- height:24px;
- width:24px;
- }
- .FilledStarCss {
- background-image: url(/Image/filledstar.png);
- height:24px;
- width:24px;
- }
- .EmptyStarCss {
- background-image: url(/Image/star.png);
- height:24px;
- width:24px;
- }
- .WaitingStarCss {
- background-image: url(/Image/waitingstar.png);
- height:24px;
- width:24px;
- }
- </style>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <h2 style="color:DarkBlue; font-style:italic;">
- ASP.NET Ajax Rating - How to use OnChanged
- <br /> event in asp.net Rating
- </h2>
- <hr width="500" align="left" color="LightBlue" />
- <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
- </asp:ToolkitScriptManager>
- <table border="0" cellpadding="4" cellspacing="4">
- <tr>
- <td>
- <asp:Image
- ID="Image1"
- runat="server"
- ImageUrl="~/Image/RedBird.jpg"
- Height="250"
- />
- </td>
- <td>
- <asp:Label
- ID="Label1"
- runat="server"
- Font-Size="X-Large"
- Font-Italic="true"
- Font-Names="Comic Sans MS"
- >
- </asp:Label>
- <br /><br />
- <asp:Label
- ID="Label2"
- runat="server"
- ForeColor="SandyBrown"
- Font-Size="Large"
- Text="Rate this image"
- >
- </asp:Label>
- <br />
- <asp:Rating
- ID="Rating1"
- runat="server"
- StarCssClass="StarCss"
- FilledStarCssClass="FilledStarCss"
- EmptyStarCssClass="EmptyStarCss"
- WaitingStarCssClass="WaitingStarCss"
- AutoPostBack="true"
- OnChanged="Rating1_Changed"
- >
- </asp:Rating>
- </td>
- </tr>
- </table>
- </div>
- </form>
- </body>
- </html>
2 comments:
wow, you are doing a good work, bro
thankx bro
Post a Comment