Can I access the height / width of the HTML control I just created in C #?

I am creating div elements from the code behind this code -

System.Web.UI.HtmlControls.HtmlGenericControl dynDiv =
    new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
dynDiv.ID = "dynDivCode";
dynDiv.Style.Add(HtmlTextWriterStyle.BackgroundColor, "Gray");
dynDiv.InnerHtml = "I was created using Code Behind";
this.Controls.Add(dynDiv);

After creating, I want to access its height and width. Can this be done? Or was it not displayed on the screen at that moment so that its properties are available?

EDIT: I want to access the newly created div width (DIV1), but I also want to change the width of another div control (DIV2) created based on the width of DIV1. So I want to read and resize two different div tags

+3
source share
2 answers

โ€‹โ€‹ ""; , . / "CSS" / CSS, .

, CSS, , Javascript (jQuery), DIV.

+3

.css, , . , id div1 div2

.css :

#div1 {
    width: 55%;
    height: 50%;
}

#div2 {
    width: 45%;
    height: 50%;
}

, div, wrappedDiv , , .css.

#wrappedDiv {
    width: 1024px;
    height: 768px;
}

.css <head>

<link href="~/Content/myNewStyles.css" rel="stylesheet" type="text/css" />
0

All Articles