开发者

How to hide the button

开发者 https://www.devze.com 2023-01-28 10:30 出处:网络
I write the some code in button eventI used the javascript and call the butto开发者_运维技巧n event it is working fine here my problem isi want hide the button

I write the some code in button event I used the javascript and call the butto开发者_运维技巧n event it is working fine here my problem is i want hide the button i do this ways visible=false this time the button event is not firing enable =false this time also button event is not firing how can isolve this problemA


If you want to do it using JavaScript

<head>
    <script type="text/javascript">
        function Hide(id) {
            document.getElementById(id).style.visibility = 'hidden';
        }
    </script>
</head>
...
<asp:Button ID="myButtonId" runat="server" OnClientClick="Hide('myButtonId')" Text="Hide Me" />

Or if you're trying to do it in code behind

YourPage.aspx

<asp:Button ID="myButtonId" runat="server" onclick="myButtonId_Click" Text="Hide Me" />

YourPage.aspx.cs

protected void myButtonId_Click(object sender, EventArgs e) {
    myButtonId.Visible = false;
}

Granted, this will result in a postback and your entire page will refresh. So if you don't want that to happen but still want to use the code behind approach, use an UpdatePanel.


"Visible" is the property of asp:Button(Server) but not input:button(Client).

0

精彩评论

暂无评论...
验证码 换一张
取 消