You must Sign In to post a response.
  • Category: ASP.NET

    Asp.net enabledproperty set to true but in GUI button is showing as disabled

    Hi,

    In my code I am disabling buttons in page load and enabling them in a function where certain rules are met. I switched on quick watch, the button.enabled property is set to false is page_Load and changing to true wherever I am setting enabled=true; But button is showing disabled on the form. I don't know what to do. Here is the button css class

    .Button
    {
    font-weight: bold;
    font-size: 9pt;
    color: #003366;
    font-family: Verdana, Arial;
    background-color: #e5ebf0;
    border-style:outset;
    cursor:pointer;
    cursor:url(/Images/H_POINT.CUR);
    }

    .Button[disabled]
    {
    font-weight: bold;
    font-size: 9pt;
    color: gray;
    font-family: Verdana, Arial;
    background-color: #e5ebf0;
    border-style:outset;
    cursor:auto;

    }
  • #765872
    Hi,

    In some where button enabled property has been set to false, due to that it is not enabling, request you to debug the code(if it is server side code) and check, if you think this is because of client side script then debug the code in browser by press F12 in keyboard and keep breakpoint and check each and everyline.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #765876
    I think your page load gets called again on button click and again make button disabled.
    as per asp.net page lifecycle, on postback each page gets disposed and recreated again, so Page_load gets call on each event, have you put Not page.IsPostback condition In page load, to avoid re-loading of page
    OR
    you can use javacript for enabled and disabled

    function Enable() {
    $("#btn1").attr('disabled', false);
    }
    function Disable() {
    $("#btn1").attr('disabled', true);
    }

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #765895
    Hi,
    When u set enabled=true; at server side, try setting css class again as follows:
    btn1.CssClass = "Button";
    OR
    btn1.Attributes.Remove("CssClass");
    btn1.Attributes.Add("CssClass ", "Button");
    Hope it helps.!


  • Sign In to post your comments