Re: [問題] RadioButton選取之後的控制項致能與否??

看板Ajax作者 (JOJO)時間13年前 (2012/08/04 12:02), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串2/2 (看更多)
你主要問題是在於 asp.net的元件id跟實際在cient端的id是不一樣的 例如你的DropDownList在server上他的id是DropDownList1 但是在server render HTML的時候 他其實還是一個 <input> 然後他的id也會被改變 而javascript 是在cient執行的語言 所以你去找DropDownList1 跟 DropDownList2這兩個id其實是不存在的 你必須要用<%= DropDownList1.ClientID %>來獲得他cient的id 這是asp.net為了確保id的唯一性的關係 ※ 引述《kiyasuto1 (kiy)》之銘言: : 各位前輩好,小弟寫ASP.NET遇到一的問題 : 有關JAVASCRIPT如下 : function fncEnable() { : if (RadioButton1.checked) { : document.DropDownList1.disabled = false; : document.DropDownList2.disabled = true; : } : else { : document.DropDownList1.disabled = true; : document.DropDownList2.disabled = false; : } : } : 而HTML檔如下 : <asp:RadioButton ID="RadioButton1" runat="server" Onclick="fncEnable()" : GroupName="r"/> : <asp:RadioButton ID="RadioButton2" runat="server" GroupName="r" /> : <br /> : <asp:DropDownList ID="DropDownList1" runat="server" > : </asp:DropDownList> : <asp:DropDownList ID="DropDownList2" runat="server" > : </asp:DropDownList> : 但是都沒有反應...請前輩不吝指教!!感謝~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 124.9.129.212

08/04 12:10, , 1F
那我要怎麼改呢???
08/04 12:10, 1F

08/04 16:40, , 2F
本文已經解釋怎麼解啦
08/04 16:40, 2F
文章代碼(AID): #1G79xmze (Ajax)
文章代碼(AID): #1G79xmze (Ajax)