Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7044347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:23:57+00:00 2026-05-28T02:23:57+00:00

I have done a code to disable a control when user clicks on a

  • 0

I have done a code to disable a control when user clicks on a control. On my form i am having a TextBox and a DropDown. When user clicks on a TextBox i will disable the DropDown like that when click on DropDown i will disable the TextBox which works fine.

But when the user clicks on Disabled control i would like to enable that control. Means if i click on TextBox which was disabled i would like to Enable it like that for dropdown too..

My sample Script is as follows

<script type="text/javascript">

function toggleDropDownList1()
{
var d=document.getElementById("<%= DropDownList4.ClientID %>");
if(d.disabled)
{
d.disabled=false;
}
else
{
 document.getElementById("<%= TextBox1.ClientID %>").disabled = true;
}
}
function toggleDropDownList2()
{
 document.getElementById("<%= DropDownList4.ClientID %>").disabled = true;
}
</script>

Design

<asp:TextBox ID="TextBox1" runat="server" onclick="toggleDropDownList2();"></asp:TextBox>
        <asp:DropDownList ID="DropDownList4" runat="server" onclick="toggleDropDownList1();">
            <asp:ListItem Text="One" Value="1"></asp:ListItem>
            <asp:ListItem Text="One" Value="1"></asp:ListItem>
        </asp:DropDownList>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:23:57+00:00Added an answer on May 28, 2026 at 2:23 am

    The idea is to place a div in front of dropdown list, and this div accept the onclick event.

    The issue here is that the div can not place so easy in front of dropdown list. To place it you need to do that dynamically and use the absolut position.

    I make here a small code, and test it and working. I have left the background color RED on div to see where it is. Some details I left it to you, eg to find the width and height of your control list, I place the onclick, you can place back the double click, And just remove the red background.

    <script type="text/javascript">
    function toggleDropDownList1()
    {
        var MyDiv = document.getElementById("DivForClick");
        MyDiv.style.display = "none";
    
        var d=document.getElementById("<%= DropDownList4.ClientID %>");
        if(d.disabled)
        {
            d.disabled=false;
        }
        else
        {
            document.getElementById("<%= TextBox1.ClientID %>").disabled = true;
        }
    }
    
    function toggleDropDownList2()
    {
        document.getElementById("<%= DropDownList4.ClientID %>").disabled = true;
    
        var MyDdl = document.getElementById("<%= DropDownList4.ClientID %>");
        var MyDiv = document.getElementById("DivForClick");
    
        MyDiv.style.display = "block";
        MyDiv.style.left = MyDdl.style.left;
        MyDiv.style.top = MyDdl.style.top;
    
        // need to find the height/width
        // MyDiv.style.height = MyDdl.style.height;
        // MyDiv.style.width = MyDdl.style.width;   
    }
    </script>
    

    and the asp code.

    <asp:TextBox ID="TextBox1" runat="server" onclick="toggleDropDownList2();"></asp:TextBox>
    
    <br /><br />
    
    <div id="DivForClick" onclick="toggleDropDownList1();" style="z-index:999;position:absolute;left:0;top:0;height:20px;width:40px;background-color:Red;display:none;">
    </div>
    
    <asp:DropDownList ID="DropDownList4" runat="server" onclick="toggleDropDownList1();" style="z-index:2;">
       <asp:ListItem Text="One" Value="1"></asp:ListItem>
       <asp:ListItem Text="Two" Value="2"></asp:ListItem>
    </asp:DropDownList> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hidden worksheets/workbooks have some limitations to what can be done in VBA code, like
I have done the following code in JavaScript to put focus on the particular
Quick question, What have I done wrong here. The purpose of this code is
Has anyone done this / have some example code?
I have just started using jQuery and although following code gets the job done,
I have found myself doing this in my code to 'cache' the work done
I have done a bit of research into this and it seems that the
I have done the global hotkeys for two key combination using the below code.
I am creating a web user control for showing Alert on AspxGridView Columns(Delete/Edit) click
How can I disable the dangerous eval function? Can that be done using ini_set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.