I am trying to write a client side function in javascript to determine what is the selected item in the drop down. But I can not figure out what the selected item is.
Hi apalcer,
In javascript, you can get the selected item of the WebDropDown by using:
$find('WebDropDown1').get_selectedItem()
or :
$find('WebDropDown1').get_selectedItemIndex()
in case you wish to access just the index of the selected item.
You can find the CSOM documentation for the WebDropDown control at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0/?page=WebDropDown~Infragistics.Web.UI_namespace.html
Please contact me if you have any questions.
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://ko.infragistics.com/support
I am trying to utilize this $find syntax in my Javascript to access the selected index in my WebDropDown, but I keep getting this error, "Microsoft JScript runtime error: Sys.ArgumentTypeException: Object of type 'Object' cannot be converted to type 'String'. Parameter name: id". This is what the markup for the WebDropDown looks like on my page:
<ig:WebDropDown ID="lstPractice" runat="server" EnablePaging="false" PageSize="10"EnableRenderingAnchors="false" ForeColor="Black" DataSourceID="lstPracticeSqlDataSource"AutoPostBack="true" Visible="true" Width="375" selectedValue='<%# Bind("dept_cd") %>'OnSelectedIndexChanged="lstPractice_OnSelectedIndexChanged" > <DropDownItemBinding TextField="dept_desc" ValueField="dept_code" /></ig:WebDropDown> This is what my Javascript code looks like that is attempting to get the WebDropDown's selected item index:
function OnPageLoadProcess2ndaryPractDDL() { var CallingDDL_ID; var selText; var selValue; var selIndex; CallingDDL_ID = FormView1 + '_lstPractice'; var CallingDDL = document.getElementById(CallingDDL_ID);--The following line of code is what generates the error! selIndex = $find(CallingDDL).get_selectedItemIndex(); if (selIndex != -1) { selValue = CallingDDL.options[selIndex].value; selText = CallingDDL.options[selIndex].text; }else{ selValue = -1; selText = -1; }}
What is the proper syntax to get the WebDropDown's selected index? What is generating the error?Thank you,Chris