locked
ajax rating control onchange fires twice RRS feed

  • Question

  • User-62667992 posted

    hello 

    ive posted this problem before but didnt get response

    ive a rating control whose onchange event fires twice when i click on the stars ive no idea why here is the code

    markup

     <ajaxToolkit:Rating ID="Rating1" runat="server"  StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
        FilledStarCssClass="FilledStar" CurrentRating="1" OnChanged="Rating1_Changed"></ajaxToolkit:Rating>

    code behind file

    protected void Rating1_Changed(object sender, AjaxControlToolkit.RatingEventArgs e)
            {
                int VV = 3;
    
                string constr = ConfigurationManager.ConnectionStrings[1].ConnectionString;
                using (SqlConnection con = new SqlConnection(constr))
                {
                    using (SqlCommand cmd = new SqlCommand("INSERT INTO Rating VALUES (@rating,@id)"))
                    {
                        using (SqlDataAdapter sda = new SqlDataAdapter())
                        {
                            cmd.CommandType = CommandType.Text;
                            cmd.Parameters.AddWithValue("@rating", VV);
                            cmd.Parameters.AddWithValue("@id", '1');
                            cmd.Connection = con;
                            con.Open();
                            cmd.ExecuteNonQuery();
                            con.Close();
                        }
                    }
                }
    
               
                
    
            }

    any ideas?

    Thursday, August 18, 2016 7:47 AM

Answers