Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using an Ajaxtoolkit ComboBox in a webform page and I need to check if the user has selected (click on) a drop down value other than the one displayed. I need to do this client side. Is there any way of adding a javascript function which will trigger when the dropdown value is changed. The SelectedIndexChanged event does not trigger until postback which is no good.

here is the code from the project
<br />
<ajaxToolkit:ComboBox ID="ComboBox1" runat="server" AutoPostBack="false"   OnSelectedIndexChanged="ComboBox1_SelectedIndexChanged" >
</ajaxToolkit:ComboBox>
 <br />



public void Page_Load(object sender, EventArgs e)
        {
            ComboBox1.Items.Add("Test Item 1");
            ComboBox1.Items.Add("Test Item 2");
            ComboBox1.Items.Add("Test Item 3");
        }

        public void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
        }



appreciate any advise on how to achieve this

What I have tried:

searched for examples - but found none. Tried adding an eventlistner but did not work.
Posted
Updated 16-Jul-17 20:12pm

1 solution

<script type="text/javascript" language="javascript">
function SetAllCheckBoxes(FormName, AreaID, CheckValue)
{
if(!document.forms[FormName])
return;
var objCheckBoxes = document.getElementById(AreaID).getElementsByTagName('input');
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = CheckValue;
else
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = CheckValue;
}
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900