J-J
J-J

Reputation: 1113

How to set asp panel height using jquery or javascript?

I have problem on setting the height of asp panel using javascript. I used below code to do this but didn't work.

<script type="text/javascript">
  $(function() {
  var sheight = $(window).height();
  $("#paneldata").height(sheight-240);
  });
</script>

What must be the problem with my code?

Thanks in advance.

Upvotes: 1

Views: 2034

Answers (1)

Kartikeya Khosla
Kartikeya Khosla

Reputation: 18883

I think the problem is that asp.net has server side controls then get target id this way(and fix other issue also as shown below) :

<script type="text/javascript">
  $(function() {
  var sheight = $(window).height();
  $("#<%=paneldata.ClientID %>").height((sheight-240) + "px");
  });
</script>

OR(If you are using ClientID in Static Mode) then try this only :

 <script type="text/javascript">
   $(function() {
    var sheight = $(window).height();
    $("#paneldata").height((sheight-240) + "px"); // add 'px' with height as shown here
   });
 </script>

Upvotes: 2

Related Questions