How can i set div height  dynamically

Posted on 2008-11-04
Last Modified: 2013-11-19
I having a  placeholder it contains an usercontrol. So our placeholder contents  and  size varies every time.  Our need is on a menu selection we wants to place a div over that placeholder. But the issue is we want that div in placeholder height and width. Is any solution for this issue?


Logics Lab
Question by:logicslab
    LVL 4

    Expert Comment

    try this,

    <div id="dynamicDiv" runat="server" style="border:solid 1px #dcdcdc"></div>

    dynamicDiv.Style.Add("height", "height of placeholder")
    LVL 3

    Accepted Solution

    Well if your normale css is fine then you just do the following:

    #1, if the div is in the placeholder: give it height and width 100%.
    #2, if the placeholder is in the div: do nothing.

    #1, Depending how you want it the div can take the height and with of the parent container which would be an placeholder here.

    #2, If the placeholder is inside the div then it will automatically extend the size of the div around it since that div has a height which by default extend.

    With kind regrads,

    Kevin Hendricks
    LVL 44

    Expert Comment

    Specify NO height, only a width.   The DIV will expand to fill the content going into it, so your problem is solved because the content controls the height of the DIV.  If there is a containing DIV, leave the height of that unspecified too.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
    Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System ( introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    794 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

    15 Experts available now in Live!

    Get 1:1 Help Now