ComboBox loses viewstate

2 posts, 0 answers
  1. Robin
    Robin avatar
    2 posts
    Member since:
    Aug 2010

    Posted 10 Sep 2010 Link to this post

    I'm having an issue when I clear the selected value of a ComboBox via client side javascript.  The box appears to remove the selected text, but on postback the original text is still selected (and displays in the ComboBox's textbox).  In other words, clicking the reset button does not clear my selection from the ComboBox.

    Here's the javascript:

     

    <script language="javascript" type="text/javascript">
    function clearAllControls() {

     

    var vendor = $find("<%= ddVendor.ClientID %>"); 
    if (vendor!=null) {
    vendor.trackChanges();

     

     

    vendor.set_text(

    "");
    vendor._applyEmptyMessage();

     

     

    vendor.commitChanges();

    }

     

    return false;
    }
    </script>

    I've also tried:

     

     

     

    <script language="javascript" type="text/javascript">
    function clearAllControls() {

     

    var vendor = $find("<%= ddVendor.ClientID %>");
    if (vendor!=null) {
    vendor.clearSelection();
    vendor.commitChanges();

     

     

     

    }

     

    return false;
    }
    </script>

    Here's the aspx:
    <asp:Button ID="btnReset" runat="server" ResourceId="NewOrderSearch_ResetButton" Text="Reset" OnClientClick="clearAllControls(); return true;" CausesValidation="false" />

     

     

     


     

     

     

     

     

  2. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 10 Sep 2010 Link to this post

    Hello Robin,

    I noticed in your second approach that you didn't add vendor.trackChanges(). I don't know if that's a mistype when you wrote in the forum or if that is what you used. If it was a mistype, try setting the selectedIndex of the RadComboBox to -1, to remove the selected item.

    I hope that helps.
Back to Top