Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2005-05-10
Medium Priority
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
  • 3
LVL 38

Expert Comment

ID: 13973704
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

PaulHews earned 800 total points
ID: 13973725
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

ID: 13973729
Note that the variable should be Public...

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview

564 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