VB.Net/ASP.Net - Programatically Enable HTML button

Posted on 2005-05-10
Last Modified: 2008-02-26

I have a page that has both asp:buttons and HTML buttons.  The page does a Search.  When I first display the search page, all buttons (both asp and html) are disabled.   See example below:
<asp:button id="BtnDelete" CommandName="Delete" tabIndex="15" runat="server" ForeColor="Crimson" Text=" Delete "
      Enabled="False" CssClass="ButtonClass"></asp:button>

<input class="ButtonClass" id="BtnDuplicate" onclick="javascript:BtnDuplicate_Click()"                               disabled tabIndex="16" type="button" value="Duplicate >>" width="70px">

<asp:button id="BtnClear" CommandName="Clear" tabIndex="17" runat="server" width="90px" Text="Clear Form"  
               Enabled="False" CssClass="ButtonClass"></asp:button>

Once the Search is successful, I need to open up (Enable) all the buttons.  

My question is on the HTML Input button (BtnDuplicate - the 2nd one above) which is set to 'disabled' in the .aspx.   For ASP buttons, I know how to enable them (BtnDelete.Enabled = True), BUT HOW DO I PROGRAMATICALLY ENABLE A HTML BUTTON ???
I don't have an 'event' to go after either, the BtnDuplicate needs to be enabled after the search is performed and the record is successfully found on the database. Help, please...msyed1.
Question by:msyed1
    LVL 38

    Expert Comment

    For this example, you would need a variable in code behind called mButtonsDisabled.  If true or false when the page is rendered, it will dynamically add/leave out the disabled attribute.

    <input class="ButtonClass" id="BtnDuplicate" onclick="javascript:BtnDuplicate_Click()"                          <%=iif(mButtonsDisabled, "Disabled", "" %>  tabIndex="16" type="button" value="Duplicate >>" width="70px">

    LVL 38

    Accepted Solution

    Correction, missed the closing bracket.

    <input class="ButtonClass" id="BtnDuplicate" onclick="javascript:BtnDuplicate_Click()"  
                <%=iif(mButtonsDisabled, "Disabled", "") %>  tabIndex="16" type="button" value="Duplicate >>" width="70px">
    LVL 38

    Expert Comment

    Note that the variable should be Public...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now