This is a migrated thread and some comments may be shown as answers.

TextChanged at Client-Site

3 Answers 141 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Franz Wunderlich
Top achievements
Rank 1
Franz Wunderlich asked on 20 Aug 2008, 09:55 AM
Hello,
 I have a default Dropdownlist with the ID="lstKostenart". Programmatically I call the following Javascript in the Page_Load event.
lstKostenart.Attributes["onchange"] = "getValue('" + lstKostenart.ClientID + "', '" + txtBetrag.ClientID + "');";
When the selected item of the Dropdownlist include a char "@", the Javascript function getValue() shows an Button via btn.style.visibility = 'visible';

My Question now.

I want to do the same with the RadComboBox. There is no client-Side onchange event and the cmbKostenart.ClientID (ClientID of the Combobox) don't work also. The example in the documentation with "var combo = $find("<%= cmbKostenart.ClientID %>");" don't work ditto.
What can I do, that the Page_Load event calls the Javascript getValue(with according parameters) or alternatively a second new function.

Thanks

3 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 20 Aug 2008, 11:48 AM
Hello Franz ,

You can use the OnClientKeyPressing,OnClientSelectedIndexChanging and OnClientSelectedIndexChanged client side events of RadComboBox to complete your task.

Please see the attached project. This project illustrates also that $find("<%= cmbKostenart.ClientID %>"); works as expected at our side.

Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Franz Wunderlich
Top achievements
Rank 1
answered on 20 Aug 2008, 02:53 PM

Hello,

in our environment, the RadComboBox is filled to following:

in ...ASPX

<telerik:RadComboBox ID="cmbKostenart" runat="server"

Enabled="false" Visible="false"

OnClientSelectedIndexChanged="OnClientSelectedIndexChanged"

OnSelectedIndexChanged="cmbKostenart_SelectedIndexChanged" />

in ...ASPX.CS

Dictionary<short, string> dic = new Dictionary<short, string>();
dic = StammdatenProxy.KostenartenTexte;
cmbKostenart.Items.Add(
new Telerik.Web.UI.RadComboBoxItem( "", "" ) );
foreach (KeyValuePair<short, string> kvp in dic) {
    cmbKostenart.Items.Add(
new Telerik.Web.UI.RadComboBoxItem(kvp.Value,    
        kvp.Key.ToString() ) );
}

The Display of HTML-Sourcode with an Texteditor shows following:

<div id="ct100_contentHolder_cmbKostenart_DropDown"
  class="RadComboBoxDropDown_skins" style="...
  <div class="rcbScroll rcbWidth ...
  <ul class="rcbList" style="...
    <li class="rcbItem "> </li>
    <li class="rcbItem ">Bahnfahrt ab 50km 241</li>
    ...
    <li class="rcbItem ">Hotel Inland 260&#160;...&#160; @218</li>
    ...
    etc.
    ...
  </ul></div></div>

I think, that is the point, why don't founded the ClientID with $find

When I write

var combo = $find("<%= cmbKostenart.ClientID %>")

then comes a Javascript-Error, because the combo-object is null.

0
Rosi
Telerik team
answered on 21 Aug 2008, 07:39 AM
Hello Franz ,

The reason for the problem is that you have set the Visible property of RadComboBox to false. Then the RadComboBox is not rendered on the page.

To solve the problem I suggest you call the $find("..") method after you make RadComboBox visible or do not set the Visible property to false. Instead, you can wrap the combo with a div with style="display:none".


Hope this helps.

Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Franz Wunderlich
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Franz Wunderlich
Top achievements
Rank 1
Share this question
or