views:

301

answers:

1

Hi All,

I have a textbox and a dropdown list on an aspx webform. The user would type in a number and then submit and the dropdown would be populated with values relevant to the typed word. If the user types a new term in the text box, I want to truncate the dropdown and when the user submits, it would submit only the text and no dropdown value (actually an empty string is ok). As the user navigates through the dropdown the page is updated with data relevant to the text and the dropdown value. I am using the following jQuery

function removeCoverageOptions() {
$("#ctl00_DefaultContent_txtClaimNumber").keypress(

    function() {
        $("#ctl00_DefaultContent_ddCovCert").find("option").remove();


    }
);

}

I am running that on $(function(){ removeCoverageOptions(); });

It does remove the option items in the UI, but when I submit the form and debug... in page load var claimNum = txtClaimNumber.Text; var certSeq = ddCovCert.SelectedValue;

claimNum is the correct newly typed text, but certSeq still has "999", the last selected value. Any ideas on how I can correct this. When I change claimNum, I intend certSeq to be an empty string. Is it maybe a viewstate issue?

Thanks, ~ck in San Diego

A: 

Sounds like a viewstate issue. Why not set EnableViewState to false as it looks like you don't need it for anything. This will ensure that the DropDownList will never have anything in it when posted back to the server.

Kelsey
The DropDownList control requires ViewState to populate the SelectedValue property.
Phaedrus
Yes I tried that. I do need the selected value sometimes as I need to retrieve data relevant to both the text and the dropdown values.
Hcabnettek
@Hcabnettek Did you ever get this sorted out? You could change your textbox to use a client side script to set the selected value to blank when the textbox data changed so that when the post happens and the textbox has changed, the dropdownlist would always have a blank selection.
Kelsey