0
我在我的asp.net網頁中有一個下拉列表。它是一個服務器端控件。我正在做一個ajax調用,並在ajax調用中,我將一個新項目添加到ddl並將其設置爲選定。它在頁面上顯示得很好。但是,當我回發所選項目時,會在下拉列表中顯示舊選定項目。DropDownList選擇不反映在服務器端
// ddlCaseNumber is the id of the dropdownlist and its clientid property is set
// to static.
// Removes the selected attribute of selected selected item .
$('#ddlCaseNumber option:selected').removeAttr("selected");
// Add the new item to dropdownlist.
$('#ddlCaseNumber').append('<option selected="selected" value=' + crmid + '>'
+ crmid + '</option>');
// Code behind code to get the new value.
// This line is giving the old value instead of giving new value.
string strNewValue = ddlCaseNumber.SelectedItem.Value;
任何人都可以請告訴我如何在代碼後面添加新項目嗎?
在此先感謝。
請參閱http://stackoverflow.com/questions/1271172/options-added-to-select-by-javascript-lost-in-postback – 2012-07-20 08:18:22