使用JavaScript禁用文件上载控制

时间:2012-07-24 08:49:11

标签: javascript jquery asp.net file-upload

如何使用Javascript禁用或启用.NET框架的文件上传控件?

有没有人有想法,请帮助。

提前致谢。

2 个答案:

答案 0 :(得分:1)

尝试这样做:

<script type = "text/javascript">
    function EnableDisable(rbl) {
        var rb = rbl.getElementsByTagName("input");
        document.getElementById("<%=FileUpload1.ClientID %>").disabled = true;
        for (var i = 0; i < rb.length; i++) {
            if (rb[i].value == 1 && rb[i].checked) {
                document.getElementById("<%=FileUpload1.ClientID %>").disabled = false;
            }
        }
    }
</script>



<form runat = "server">
    <asp:RadioButtonList ID="RadioButtonList1" runat="server" onclick = "EnableDisable(this)">
        <asp:ListItem Text = "Yes" Value = "1"></asp:ListItem>
        <asp:ListItem Text = "No" Value = "2"></asp:ListItem>
    </asp:RadioButtonList>
    <asp:FileUpload ID="FileUpload1" runat="server" disabled = "disabled"/>
</form>

答案 1 :(得分:0)

使用

document.getElementById(FileUploadControlID).disabled = true;