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

[Solved] onclientselectedindexchanged and onload

2 Answers 193 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 16 Aug 2009, 10:05 PM
Hi All,

I am facing some issues:

1) I have a databound combobox which gets data from sql source from codebehind file. The combobox fills fine, but when Im trying to select an item, the items gets marked, but the box doesnt close. I have a masterpage with RadScriptManager and RadAjaxManager.

Thats how the combobox part of the aspx file looks like

<telerik:RadComboBox ID="rcbPLZ" Runat="server"
                AppendDataBoundItems="True" EnableLoadOnDemand="True"
                onclientselectedindexchanged="OnClientSelectedIndexChanged"
                onclientselectedindexchanging="LoadOrt"
                onitemsrequested="rcbPLZ_ItemsRequested" AllowCustomText="True"
                ShowDropDownOnTextboxClick="False">
  </telerik:RadComboBox>

the javascript function is

function  OnClientSelectedIndexChanged(combo, eventArgs)
{  
     // alert("OnClientSelectedIndexChanged");
      OrtCombo.set_text("");
      var PLZstring = combo.get_text();
      combo.set_text(PLZstring.substring(0,5));
      OrtCombo.set_text(PLZstring.substring(6,PLZstring.length-1)); //
      LoadStrasse(combo, eventArgs);
}


Also, and that the second issue, at onload I want to set certain strings for two comboboxes and it has worked, but it is not and Im not sure what I did wrong:

<script language="javascript" type="text/javascript" >
    
var PLZCombo;
var OrtCombo;
var StrassenCombo;

function onload()
{  
   PLZCombo =$find("<%= rcbPLZ.ClientID %>");
   OrtCombo =$find("<%= rcbOrt.ClientID %>");
   StrassenCombo =$find("<%= rcbStrasse.ClientID %>");
   StrassenCombo.set_text("a");
   PLZCombo.set_text("b");
}

Maybe Im putting the javascript into the wrong place, I just put it below a table...

Any hints are very much appreciated..

Best wishes

iandi

2 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 20 Aug 2009, 11:34 AM
Hello Andreas,

I suppose you are calling the onload function in window or body load events? If I am correct, please note that the client objects are not initialized yet in this moment. You need to use the pageLoad alias or Sys.Application.add_load approach. Please check this blog post for more information:
Don't Use BODY ONLOAD in ASP.NET AJAX Websites

I am not sure about the closing issue though. Does it happen in IE only? What happens if you click over the text of the item?

All the best,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Andreas
Top achievements
Rank 1
answered on 20 Aug 2009, 02:48 PM
Hello Veselin,

many thanks for your answers and the hints included.

I will go through the blog and will make the changes you've suggested.

Thanks again for your response

Take care

Andreas
Tags
ComboBox
Asked by
Andreas
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Andreas
Top achievements
Rank 1
Share this question
or