views:

278

answers:

5

The coding is done using VS2008 There are two divs in my page namely "dvLeftContent" and "dvRightContent". I cannot statically set the height of the pages since "dvRightContent" have variable heights on various pages (Master Pages are used here) Is there a client side function(javascript or jquery) that takes the height of the right div and assigns it to left div?

A: 

Using jQuery:

$("#dvRightContent").bind("resize", function(){
    $("#dvLeftContent").css('height', $("#dvRightContent").css('height')); 
});
micahwittman
A: 

Thanks micahwittman. Some minor changes

   $("#dvRightContent").resize(function(){
        $("#dvLeftContent").css("height", ($("#dvRightContent").attr("offsetHeight") - 250 ) +"px");
    });

Its because height will give only "auto" in this case as its set like that

naveen
Interesting. You're welcome, btw. Also, just did a quick edit to fix typo on my username.
micahwittman
A: 

There is also a jQuery plugin which does the job for you: Equalize

It handles both the scenario where rightcol is larger then leftcol or where leftcol is larger than rightcol. It also allows you to specify which element inside either leftcol or rightcol should get the space added.

mlarsen
A: 

Hi mlarsen, Will this plugin works if the div changes(using js without a postback) after the page is loaded?

naveen
I cannot see why it wouldn't. You just call jQuery.Equalise("#col1", "#col2") again after the content has changed.
mlarsen
A: 

Hi micahwittman, yeah i know. I posted it for any future reference. Thanks pal

naveen