开发者

How to 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜