set dropdownlist value client side

2 posts, 0 answers
  1. Brian
    Brian avatar
    3 posts
    Member since:
    Dec 2010

    Posted 21 Dec 2012 Link to this post

    Hi, we're using the FormDecorator and I notice on the front end the dropdownlist renders as a div with spans instead of a traditional html select list.

    When I try to use jquery to set the selected value after the control renders it doesn't change. I'm guessing because this is technically not a select list anymore.

    Is there any work around to this?
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 25 Dec 2012 Link to this post

    Hello Brian,

    Handling elements of type select are quite complex and not all their attributes can be monitored, especially in the way jQuery changes them ($("#theSelect").val(newIndex)). What I can suggest is using simple JavaScript to set the new selected item:
    $get("<%=ddl1.ClientID %>").selectedIndex = 2;

    I am also attaching here a simple page that shows this in action.

    Kind regards,
    Marin Bratanov
    the Telerik team
    Explore the entire set of ASP.NET AJAX controls we offer here and browse the myriad online demos to learn more about the components and the features they incorporate.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top