我在應用程序中有一個級聯的DropDownList。級聯下拉列表的內容足夠小,以至於不需要使用AJAX/JSON去數據庫來獲取內容,我只是在客戶端JavaScript中這樣做(這是一個子集數據):在客戶端JavaScript修改後獲取DropDownList的值
var val = typeList.value;
var applyTimeList = document.getElementById('clientid');
for (var q=applyTimeList.options.length; q>=0; q--)
applyTimeList.options[q]=null;
if (val == 'AutoRoute')
{
myEle = document.createElement('option') ;
myEle.value = 'SOP Processed';
myEle.text = 'SOP Processed';
applyTimeList.add(myEle) ;
} else if (val == 'Tier1Retention') {
myEle = document.createElement('option') ;
myEle.value = 'Study Processed';
myEle.text = 'Study Processed';
applyTimeList.add(myEle);
myEle = document.createElement('option') ;
myEle.value = 'Study Restored';
myEle.text = 'Study Restored';
applyTimeList.add(myEle);
myEle = document.createElement('option') ;
myEle.value = 'Study Archived';
myEle.text = 'Study Archived';
applyTimeList.add(myEle) ;
}
當我試圖訪問的DropDownList在服務器端我不能得到的價值選擇,它總是返回0作爲索引:
int index = RuleApplyTimeDropDownList.SelectedIndex;
我怎樣才能得到修改後在服務器端選擇的值?
感謝您的反饋意見,我打算試圖關注如何在服務器端獲取所選值,而不是客戶端。我編輯了這篇文章。 – 2009-07-09 21:06:16