I am using ASP.NET with C#
I have a HTMLSelect element and i am attemping to call a javascript function when the index of the select is changed.
riskFrequencyDropDown is dynamically created in the C# code behind tried:
riskFrequencyDropDown.Attributes.Add("onchange", "updateRiskFrequencyOfPointOnMap(" + riskFrequencyDropDown.ID.Substring(8) + "," + riskFrequencyDropDown.SelectedValue +");");
but it does not call the javascript function on my page. When i remove the parameters it works fine, but i need to pass these parameters to ensure proper functionality.
Any insight to this problem would be much appreciated
Are your parameters numeric or alphanumeric? If they contain letters, you’ll need to quote them in the javascript. Note the addition of the single quotes below.