Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
72 views
in Technique[技术] by (71.8m points)

How to disable a button with asp.net after certain conditions? C#

I am trying to disable a button that creates a document when the values I inserted was not recalculated. I tried something like this:

        private void EnableButton()
        {
            button.Enabled = true;
            button.Style.Remove("Opacity");
        }
        private void DisableButton()
        {
            button.Enabled = false;
            //button.Attributes.Add("disabled", "disabled"); 
            //button.Attributes.Add("disabled","true");
            button.Style.Add("Opacity", ".5");
        }

On Localhost, the 3 methods works, and it is disable and enable correctly. But on client side, even if the opacity works, the button is still clickable. I searched before asking, but could not find the solution. There is a way to verify if the button is enabled or not and disable it on asp.net file?? The button on asp.net:

<LinkButton ID="button" runat="server" Text="Save" Style="float: right"
    OnClick="button_save" ImageCssClass="button">
question from:https://stackoverflow.com/questions/66062636/how-to-disable-a-button-with-asp-net-after-certain-conditions-c-sharp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...