簡體   English   中英

使用javascript的asp.net控件

[英]asp.net controls with javascript

我知道這可能是一個簡單的解決方法,但是我似乎無法在這里解決問題...

我試圖在單擊RadioButton1時禁用過去的文本框中。

<asp:RadioButton ID="RadioButton1" runat="server" Checked="True" GroupName="DateTimeQuery" OnClick="javascript:TimeRangeClickEvent()"/>
<asp:TextBox ID="withinthepast" runat="server" Text="1"></asp:TextBox>

<script>
        function TimeRangeClickEvent()
        {
            var radio1 = document.getElementById('<%=RadioButton1.ClientID%>').checked;                

            if (radio1 == true)
            {
                var within = document.getElementById('<%=withinthepast.ClientID%>').enabled = false;
            }
        }
    </script>

有什么建議嗎?

嘗試這個

if (radio1.checked == true)
        {
            var within = document.getElementById('<%=withinthepast.ClientID%>').enabled = false;
        }

您可以添加屬性clientIdMode = static

問題可能出在“啟用”屬性上。 您可以嘗試以下方法:

啟用控件: ctl.removeAttribute("disabled")

禁用控件: ctl.setAttribute("disabled", "disabled")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM