通过JavaScript启用控件(单选按钮) [英] Enabling control(radio button) through JavaScript

查看:96
本文介绍了通过JavaScript启用控件(单选按钮)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<head runat="server">
    <title></title>
    <script type="text/javascript">
        function RadioClick() {
            alert("Hi");
            document.getElementById("FileUpload1").style.visibility = "visible";
        }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:RadioButton ID="rbClderFormt" runat="server" GroupName="Format"/>
    <asp:RadioButton ID="rdTableFormat" runat="server" GroupName="Format"/>
    <asp:RadioButton ID="rdUploadFormat" runat="server" GroupName="Format"/>

     <asp:FileUpload ID="FileUpload1" runat="server" Visible="false"/>
    </div>
    </form>
</body>







以上i代码。当我单击rdUploadFormat radioButton时,我必须更改FileUpload1的可见性。在后端我使用以下代码






The above is the code. I have to change the visibility of "FileUpload1" When I click the rdUploadFormat radioButton. In the back end I m using the following code

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                rdUploadFormat.Attributes.Add("OnClick", "return RadioClick()");
            }
        }





以上不起作用。我收到警告消息,但FileUpload不可见。



The above is not working. I am getting the alert message but the FileUpload is not visible.

推荐答案

删除Visible ='false'并将style ='display:none'添加到文件上传控件如下所述:



remove Visible='false' and add style='display:none' to your file upload control as mentioned below :

<asp:fileupload id="FileUpload1" runat="server" style="display: none" xmlns:asp="#unknown" />



并更新javascript方法,如下所示:


and update javascript method as shown below :

function RadioClick() {
        alert("Hi");
        document.getElementById("FileUpload1").style.display = "block";
    }


这篇关于通过JavaScript启用控件(单选按钮)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆