如果文本字段为空,如何为section(detail)设置可见性false [英] how to set visibility false for section(detail) if text field is empty

查看:170
本文介绍了如果文本字段为空,如何为section(detail)设置可见性false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为部分(细节)设置可见性false,但我不想压缩部分。

在框对象2文本框内有。如果文本字段为空则意味着我需要将box对象和标签设置为false,但我不想压缩section.i需要空白部分(空格)的部分没有它的数据。



注意:我需要空白部分(空格),并且对于没有数据的部分,也不应该看到框对象。我正在使用visual studio 2008 IDE。

请帮我这样做。

i want to set visibility false for the section(detail) but i don't want to suppress section.
inside the box object 2 text box are there.if text field is empty means i need to set box object and label to false but i don't want to suppress the section.i need blank section(space) for the section with don't have the data that it.

NOTE:i need blank section(space) and box object also should not visible for the section with don't have the data that it. am using visual studio 2008 IDE.
please help me to do this.

推荐答案





您可以尝试隐藏控件而不是div。

这是您可以使用的代码片段。

Hi,

You could try hiding the controls instead of div.
Here is the code snippet you could make use of.
<script type="text/javascript">
        function hideControls() {
            var txtVal = document.getElementById('MainContent_txtBx').value;
            var divToHide = document.getElementById('MainContent_dynamicContent');
        if (txtVal == '') {
            document.getElementById('MainContent_txtBx').style.display = 'none';
            document.getElementById('MainContent_lbl').style.display = 'none';
            }
        }
    </script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="hideControls()" />

        <div id="dynamicContent" runat="server" style="height:50px;border-style:solid;border-color:#ff0000 #0000ff;">
        <asp:Label ID="lbl" runat="server" Text="Sample message"></asp:Label>
        <asp:TextBox ID="txtBx" runat="server" />
        </div>
        </asp:Content>



希望这对你有所帮助。



问候,

RK


Hope this helps you a bit.

Regards,
RK


这篇关于如果文本字段为空,如何为section(detail)设置可见性false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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