0
我真的很努力與JavaScript編程,需要幫助。使用Javascript在GridView中禁用DropDownList
我想禁用6下拉列表客戶端在gridview內。下面是我目前的JavaScript,除了最後一行,我試圖禁用下拉列表之一。我認爲這個問題是因爲下拉列表在gridview中,而java找不到它們。我如何找到它們?
<script>
function EnableAndColorButtons() {
document.getElementById('<%= Submit.ClientID %>').disabled = false;
document.getElementById('<%= Submit.ClientID %>').style.background = "Lime";
document.getElementById('<%= Submit.ClientID %>').style.borderColor = "Green";
document.getElementById('<%= Cancel.ClientID %>').disabled = false;
document.getElementById('<%= Cancel.ClientID %>').style.background = "lightcoral";
document.getElementById('<%= Cancel.ClientID %>').style.borderColor = "Red";
document.getElementById('<%= InfoLbl.ClientID %>').innerHTML = '(Continue to make changes or click submit if finished)';
document.getElementById('<%= MakeChangeslbl.ClientID %>').innerHTML = 'You must click "Submit Changes" or "Cancel Changes" above before making Assignment changes below!';
//The above is working, but the below is not probaly because the drop down lists are within gridview1
document.getElementById('<%= DropDownList1.ClientID %>').disabled = true;
}
</script>
我的GridView在下拉列表中位於看起來是這樣的:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource3" DataTextField="FullDetails" DataValueField="FullDetails" Font-Size="Medium" Height="50px" OnDataBinding="DropDownlist1_DataBinding1" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" Width="230px">
</asp:DropDownList>
嘗試改變自動回假,並檢查其是否工作,我相信你寫的是工作,只是回傳造成的JavaScript這裏的問題 – Se0ng11
我需要的AutoPostBack爲下拉列表的功能好好工作。我確實嘗試將autopostback更改爲false以進行測試,並且下拉列表未被禁用。 – DannyBoy
當時......認爲這對某個人來說很容易...... – DannyBoy