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 6846593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:38:31+00:00 2026-05-27T00:38:31+00:00

I have a div with style=display:none. The div should become visible on pressing an

  • 0

I have a div with style=”display:none”. The div should become visible on pressing an html button:

function JSAdd() {
    document.getElementById('divDetail').style.display = "block";
}
    <div style="float:left">

    <div id="ctl00_MainContent_upnlLbRD">





            <select size="4" name="ctl00$MainContent$lbRD" id="ctl00_MainContent_lbRD" style="width:188px;">

    <option value="5">one</option>
    <option value="1">two</option>
</select>

    <input id="btnAdd" type="button" value="Добавить" onclick="JSAdd();" />
    <input id="btnEdit" type="button" value="Редактировать" onclick="JSEdit();" />
</div>
<div id="ctl00_MainContent_divDetail" style="display:none" clientidmode="static">
    <div id="ctl00_MainContent_upnlDescription">

            <div>

                <span id="ctl00_MainContent_lblDescription">Описание:</span>

                <input name="ctl00$MainContent$txtDescription" type="text" id="ctl00_MainContent_txtDescription" />  

                <span id="ctl00_MainContent_txtDescriptionRequiredFieldValidator" style="color:Red;visibility:hidden;">Описание является обязательным для заполнения</span>

            </div>

            <input type="submit" name="ctl00$MainContent$btnSave" value="Сохранить" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$MainContent$btnSave&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="ctl00_MainContent_btnSave" />   

I need to be able to make the div invisible again from code-behind. I cannot access the div unless it is runat="server". But when I add runat=”server”, the div doesn’t become visible on pressing the button from the javascript function above. Could you please help me with this?

Thanks,
David

  • 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-27T00:38:32+00:00Added an answer on May 27, 2026 at 12:38 am

    You can access a div in code-behind by adding the runat="server" attribute. Adding this attribute does change the way you access the element in JavaScript though:

    var el = document.getElementById("<%=div1.ClientID%>");
    if (el){
        el.style.display = "none"; //hidden
    }
    

    There are two ways to adjust the visibility from code-behind, but since you’re setting display:none in JavaScript, you’d probably want to use the same approach in code-behind:

    div1.Style["display"] = "block"; //visible
    

    In code-behind, you can also set the Visible property to false, but this is different because it will prevent the element from being rendered at all.

    EDIT

    If the div is still showing with display:none present, you probably have an unclosed tag or quote somewhere affecting the markup. Double check and make sure that the markup is valid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have the HTML below: <div style=display:none;> <span id=hello>Hey</span> </div> And I do
Suppose I have the following HTML: <div id=test> <span style=display:inline;>foo</span> <span style=display:none;>bar</span> <span style=display:inline;>baz</span>
I have a loader div defined as say for simplicity <div dojoAttachpoint=loaderDiv style=display:none;>.....</div> Now
I have this piece of code, <div id=event style=display:none;> <!-- initially hidden --> <div
I have some mark-up like so: <div class=slideshow> <div class=slide style=display:block;></div> <div class=slide style=display:none;></div>
i have the following code <div class=hitarea expandable-hitarea></div> <span class=folder>level 1</span> <ul style=display: none;>
I have an html table. Here is a simplified version: <table> <tr> <td><div style=display:
I have following HTML: <div class=olympics style=display: block; position: absolute; left: 250px; top: px;>
I have this html <div id=cont> <div id=videowrapper class=fitmein> <div id=vimeoposition style=display: block;> <div
I have such div: <div class=box> <div id=myid style=display:hidden;> <p>some stuff here</p></div> </div> when

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.