DropDownList and value

14 posts, 0 answers
  1. Paweł
    Paweł avatar
    16 posts
    Member since:
    Jan 2009

    Posted 21 Aug 2009 Link to this post

    Hello,

    I try to get decorated DropDownList value after change.
    I'm using jQuery to add event like this

    var select = $('#<%= ddlControl.ClinetID %>');
    select.change(function() {
        alert($(this).val());
    });

    event is trigered correctly, but value is always 0. I did also inspect <select> in DOM inspector, and there is also always value = 0.

    So, how to get this value if it's not changing?

    Gr,
    Pawel
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 24 Aug 2009 Link to this post

    Hello Paweł,

    Here is a small sample that shows how to achieve this:

    <head id="Head1" runat="server"
        <title></title
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> 
    </head> 
    <body> 
        <form id="form1" runat="server"
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
        <telerik:RadFormDecorator ID="FormDec1" runat="server" DecoratedControls="All" /> 
        <asp:DropDownList ID="ddlControl" runat="server"
            <asp:ListItem Value="1"></asp:ListItem> 
            <asp:ListItem Value="2"></asp:ListItem> 
            <asp:ListItem Value="3"></asp:ListItem> 
            <asp:ListItem Value="4"></asp:ListItem> 
        </asp:DropDownList> 
        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
     
            <script type="text/javascript"
                var select = $('#<%= ddlControl.ClientID %>'); 
                select.change(function() 
                { 
                    alert($(this).val()); 
                }); 
            </script> 
     
        </telerik:RadScriptBlock> 
        </form> 
    </body> 

    I hope this helps.

    Sincerely yours,
    Georgi Tunev
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Paweł
    Paweł avatar
    16 posts
    Member since:
    Jan 2009

    Posted 25 Aug 2009 Link to this post

    Hello Georgi,

    Thanks for replay, my code is 90% similar to yours, but still displays always 0.
    I tried your code on a blank new project and result was the same, it alwayd display 1 (first value from drop down).
    If i disable form decorator it works correct.

    Print screen while changeinf value 3 to 2: http://cbm.yetiz.pl/telerik/formdecorator_change.jpg
    And also screen from FireBug DOM inspector, you can sse that even if 3 is selected the value is still "1": http://cbm.yetiz.pl/telerik/formdecorator_change.jpg

    Gr,
    Paweł
  5. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 27 Aug 2009 Link to this post

    Hello Paweł,

    Are you using Firefox? I am asking you this because the code is working fine with IE, but we noticed that there is a problem with RadFormDecorator's Selects  and Firefox. We are currently working on this problem and once we have a solution, I will post it here.

    Kind regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Martin
    Admin
    Martin avatar
    585 posts

    Posted 28 Aug 2009 Link to this post

    Hi Paweł,

    I believe that the code below will work. It seems that the programatic selection of a dropdown does not behave as expected in FireFox, and we will further investigate the problem.

    <script type="text/javascript"> 
    var select = $('#<%= ddlControl.ClientID %>'); 
    var combo = document.getElementById('<%= ddlControl.ClientID %>');

    select.change(function() 
    {
     var skinnedcombo = document.getElementById('Skinned<%= ddlControl.ClientID %>');
     var skinnedoptions = skinnedcombo.getElementsByTagName('LI');
     
     if(navigator.appName == 'Netscape')
     {
      for(var i = 0; i < skinnedoptions.length; i ++)
      {
       combo.options[i].removeAttribute('selected');
       if(skinnedoptions[i].className == 'rfdSelect_selected')
       {
          combo.options.selectedIndex = i;
       }
      }
     }
    });
    </script>


    Kind regards,

    Martin Ivanov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Michael
    Michael avatar
    84 posts
    Member since:
    May 2008

    Posted 14 Sep 2009 Link to this post

    Hi

    I am having the same issue on a postback in Firefox. In IE and Safari it works, however when I do a server side postback in Firefox, the first DropDownList item is selected, unless the correct item.

    Can anyone assist with this?

    Thanks.
  8. Martin
    Admin
    Martin avatar
    585 posts

    Posted 14 Sep 2009 Link to this post

    Hello Michael,

    The issue you have reported is logged in in our to do list and is pending fixing, however at the time being we cannot provide you with a solution.

    Regards,
    Martin Ivanov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. SWAT
    SWAT avatar
    12 posts
    Member since:
    Dec 2008

    Posted 27 Oct 2009 Link to this post

    Hi Georgi,

    We had a rough day today because of the dropdown.value in javascript does not work in firefox when using the formdecorator.
    we finally added the ControlsToSkip="Select" tot he decorator, but i want to know if this matter will be fixed in the comming Q3?

    Thanks in advance,
    Ilan.
  10. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 28 Oct 2009 Link to this post

    Hello Ilan,

    Yes, the fix is ready and will be present in the Q3 release next week.


    Regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  11. Kurt
    Kurt avatar
    17 posts
    Member since:
    Aug 2006

    Posted 28 Oct 2009 Link to this post

    That is great news, as I just spent the last two hours tracing this issue.,.
  12. Fit2Page
    Fit2Page avatar
    345 posts
    Member since:
    Feb 2007

    Posted 12 Nov 2009 Link to this post

    Hello,

    I just downloaded Q3 and now my DropDownList is no longer styled by RadFormDecorator in IE an FF?

    Please advice.

    Marc
  13. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 12 Nov 2009 Link to this post

    Hi Marc,

    The decoration of SELECT elements is working fine in our demo, so I assume that the reason for the problem could be in the configuration or the logic that you are using. Please open a support ticket and send us a small sample project so we could investigate.


    Best wishes,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  14. Fit2Page
    Fit2Page avatar
    345 posts
    Member since:
    Feb 2007

    Posted 12 Nov 2009 Link to this post

    Hi Georgi,

    I found that the problem is that I have a CssClass defined on the DropDownList.
    In previous versions the select was styled by RadFormDecorator anyway but in Q3 not anymore.

    Is this a bug or intended behavior?

    BR,
    Marc
  15. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 12 Nov 2009 Link to this post

    Hi Marc,

    Yes, by design RadFormDecorator will not decorate controls that have class property - in such case we assume that the developer wants to control the look of the component.


    All the best,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017