Similar to the dozens of other threads posted with retrieving a combobox value in client-side code, I cannot get this to work. After spending the past 8 hours trying to get this to work, hopefully someone can point out what I am doing wrong.
I started with this basic code:
<%@ Page Title="" Language="C#" MasterPageFile="~/My.Master" AutoEventWireup="true" CodeBehind="MyPage.aspx.cs" Inherits="MyPage" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"head"
runat
=
"server"
>
<
title
>My Page</
title
>
<
link
rel
=
"stylesheet"
type
=
"text/css"
href
=
"/CSS/MyPage.css"
/>
<
script
type
=
"text/javascript"
src
=
"/Scripts/MyPage.js"
></
script
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"body"
runat
=
"server"
>
<
telerik:RadComboBox
ID
=
"RadComboBoxADT"
runat
=
"server"
/>
<
telerik:RadButton
ID
=
"btnSubmit"
runat
=
"server"
Text
=
"Submit"
OnClientClicked
=
"onSubmitClick"
SingleClick
=
"true"
SingleClickText
=
"Processing..."
AutoPostBack
=
"false"
/>
</
asp:Content
>
MyPage.js:
function onSubmitClick(a,b) {
var combo = $find("<%= RadComboBoxADT.ClientID %>");
alert(combo);
return;
}
running this code, combo yields "null", so any attempt to get the selected item fails as well.
I tried moving the code from a <script> file, into the content header, e.g.
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"head"
runat
=
"server"
>
<
title
>My Page</
title
>
<
link
rel
=
"stylesheet"
type
=
"text/css"
href
=
"/CSS/MyPage.css"
/>
<
script
type
=
"text/javascript"
>
function onSubmitClick(a,b) {
var combo = $find("<%= RadComboBoxADT.ClientID %>");
alert(combo);
return;
}
</
script
>
</
asp:Content
>
however, all this managed to do was yield a javascript error, onSubmitClick not found, on page load (why? if I view code, I can see it there.)
another set of eyes here would be appreciated.