Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

How to Set a Panel's Width property from Client-Side code?

$
0
0

I've defined a Panel control which sits inside a bunch of nested parent controls.  The width of the Panel is set to "100%", which is appropriate, as certain elements in the parent controls change their width depending on different circumstances.  Thus, the Panel control's width changes accordingly.

In order for ScrollBars="Both" or ScrollBars="Auto" to work properly though, I've found that I need to explicitly set the Width & Height of the Panel.  While there's no problem doing this initially, the fact is that when those other parent elements change their width, that is only monitored by client-side code.  So I took to writing code like this:

var width = sender.get_width();                          // Get the width of 'radPaneMain'
  $('[id$=_panelMucking]')[0].style.width = width + 'px';  // and use it to set the width of 'panelMucking'

That works fine in a client-side context but I discovered that when a server-side method is then called, it doesn't know about the changes made by the client-side code shown above.

So, much like one can set the value of a hidden variable on the client and have it bubble up to the server-side, I'm curious if there's something similar I can do with regard to setting the Width of a Panel?


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>