【发布时间】:2018-09-07 08:08:14
【问题描述】:
我想使用带有 Javascript 的事件更改标签的值。在我的按钮上,我有一个事件onclick,当您单击它时会转到特定功能,但我无法让他做我想做的事。例如启用或禁用一个元素。
我尝试使用普通按钮和 asp 按钮,但它不起作用。 Label 的 Visible 属性有效,因为标签消失了,但当我点击按钮时它没有出现。
这是代码:
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
function myFunction() {
var estado = document.getElementById('Label1');
estado.Visible = true;
}
</script>
<div id = "bloque1">
<asp:Label ID="Label1" runat="server" Text="Label" Font-Size="55pt" Visible="false" />
</div>
<div class = "botones">
<button onclick="myFunction()">Click me</button>
<asp:Button ID="Button1" onclick="myFunction()" runat="server" Text="Button" />
</div>
</asp:Content>
【问题讨论】:
标签: javascript asp.net button