开发者

Disable button if boolean variable is true

开发者 https://www.devze.com 2023-04-12 03:58 出处:网络
I\'ve found topics covering disabling buttons to avoid submitting twic开发者_如何转开发e (assuming this could be done via javascript), but what i need is to disable button of submit if field \"formSub

I've found topics covering disabling buttons to avoid submitting twic开发者_如何转开发e (assuming this could be done via javascript), but what i need is to disable button of submit if field "formSubmitted" in the database holds true value. otherwise this means the form has not been submitted and this submit is required. Any idea how to do this?

  <asp:TableCell>
        <asp:Button id="acceptButton" Text="Accept" runat="server" OnClick="Click"/> 
        <asp:Button id="declineButton" Text="Decline" runat="server" OnClick="DeclineRequest"/> 
    </asp:TableCell></asp:TableRow></asp:Table></form></asp:Content>

so yeh the accept and decline buttons are what i want to disable if formsubmiited variable holds true. Thanks again,


if (formSubmitted)
{
    acceptButton.Enabled = false; 
    declineButton.Enabled = false;
}


Use the Enabled property.

if( WhateverYouAreTesting == true )
{
     declineButton.Enabled = false;
}


Try something like this:

declineButton.Enabled = booleanVariable == false;

Or

declineButton.Enabled = !booleanVariable;


You can also try

acceptButton.Visible = false;


if(acceptButton.Enabled.Equals(true))
{
    acceptButton.Enabled = false;
}
0

精彩评论

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

关注公众号