如何在asp按钮单击中禁用div标签

时间:2014-04-24 07:12:36

标签: javascript jquery asp.net vb.net

按钮单击div标签已禁用,但再次启用页面加载后。如何在按钮单击

后加载页面后保持禁用状态
<script language="javascript" type="text/javascript">
    function toggledisable() {
        $(document).ready(function () {
        document.getElementById('flip').style.display = "none";
        document.getElementById('flip1').style.display = "none";
        });  

    }
</script>

1 个答案:

答案 0 :(得分:0)

您刚刚更改了客户端的display,但未更新控件的ViewState。您可以将更改后的状态保留在隐藏字段中,并使用hidden字段中没有服务器端来显示或隐藏div

还从toggledisable()

中删除document.ready

HTML

<input type="hidden" runat="server" id="hdnflip" />
<input type="hidden" runat="server" id="hdnflip1" />

的Javascript

function toggledisable() {      
    document.getElementById('<%= flip.ClientID %>').style.display = "none";
    document.getElementById('<%= flip1.ClientID %>').style.display = "none";  
    document.getElementById('<%= hdnflip.ClientID %>').value = "true";       
    document.getElementById('<%= hdnflip1.ClientID %>').value = "true";       
}

背后的代码

flip.Visible = bool.Parse(hdnflip.Value)      
flip1.Visible = bool.Parse(hdnflip1.Value)