Send both selectedText & Value to requestItems event

3 posts, 1 answers
  1. Naunton
    Naunton avatar
    70 posts
    Member since:
    Jun 2010

    Posted 18 Jan 2011 Link to this post

    Hi all,
    Please advise.
    After selected 1stCombo, then bind 2ndCombo base on 1stCombo selected value & text.
    Thant's why I need to send both selectedText & Value from ClientScript at ClientSelectedIndexChange.

    My code is as below
    <telerik:RadComboBox ID="Cbo1" runat="server"
            CssClass="label" Label="Combox1     :" Skin="WebBlue"
            OnClientSelectedIndexChanging="LoadCbo2l"
                OnItemsRequested="Cbo1_ItemsRequested"
                onclientitemsrequested="ItemsLoaded" ViewStateMode="Enabled"
                    ></telerik:RadComboBox>
     
    <telerik:RadComboBox ID="Cbo2" Runat="server" CssClass="label" Label= "Combox2 :"
                Skin="WebBlue" OnItemsRequested="Cbo2_ItemsRequested"
                OnClientItemsRequested="ItemsLoaded" ViewStateMode="Enabled">
            </telerik:RadComboBox>
     
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
         <script type="text/javascript">
     
    function LoadCbo2(combo, eventArqs) {
        var 2ndCombo;
                 var item = eventArqs.get_item();
                 2ndCombo.set_text("Loading...");
      
                 if (item.get_index() > 0) {
                          Cbo2.requestItems(item.get_value(), false);
                 }
                 else {
                     2ndCombo.set_text(" ");
                     2ndCombo.clearItems();
                 }
             }
            </script>
    </telerik:RadCodeBlock>

    With this I only get selected value at Cbo2_ItemsRequested event, when I try to get with  Cbo1.SelectedItem.Text  directly, the text I selected is not yet there.
    How can I get both, please?

    Thanks and best regards
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Jan 2011 Link to this post

    Hello Naunt,

    If you want to get the selected text of RadComboBox in 'OnClientSelectedIndexChanging' event, you can try the following code snippet.

    Java Script:
    <script type="text/javascript">
     function LoadCbo21(combo, eventArqs) {
        var item = eventArqs.get_item();
        alert(item.get_text()); //getting selected text
     </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Naunton
    Naunton avatar
    70 posts
    Member since:
    Jun 2010

    Posted 19 Jan 2011 Link to this post

    Hi Princy,

    Thanks for your very fast reply.
    I want both text and value.
    Now I change as below, then I'm going to Split() at codebehind.
    VslCombo.requestItems(item.get_text() + "_" + item.get_value(), false);


    Thanks and best regards
Back to Top