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

ComboBox loses viewstate

1 Answer 56 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Robin
Top achievements
Rank 1
Robin asked on 10 Sep 2010, 04:51 PM
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" />

 

 

 


 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 10 Sep 2010, 05:33 PM
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.
Tags
ComboBox
Asked by
Robin
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Share this question
or