Dynamic div height

  • Thread starter Thread starter Jensen bredal
  • Start date Start date
J

Jensen bredal

Hello,
How can i dynamically change the height of my <div></div> element on my
webform.

I use C# and i want this height to be set according to screen resolution,
tipically in my code behind file. I have detected screen resolution .

I tried to embbed height:<%# computedheight %> in the style of the div
ellements but that does not seem to make sens.

Many thanks in advance

JB
 
Hi,

Have a runat=server attribute and an ID for your DIV tag to create a
HtmlGenericControl on the server side. Then you can easily set the width or
height of the DIV tag on the server-side itself.

In your code-behind:

MyDivTag.Attributes["style"] = "width:100px; height:200px;";

Hope this helps?
 
You shouldn't need any coding for that. Did you try to set the height to a
percentage value like height="80%"?

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top