CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.web_forms Tags:
Item Type: NewsGroup Date Entered: 1/17/2007 7:44:15 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 9 Views: 0 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
10 Items, 1 Pages 1 |< << Go >> >|
CHolt
Asp.Net User
Getting div tag overflow logic to behave1/17/2007 7:44:15 PM

0/0

I am writing a custom composite control and I'm having a problem with rendering a table so that it will scroll horizontally correctly.  Here is my problem:

I have a control that is placed within a webform that has a structure as follows:

<div style="width: 800px">
  <table width=100%>
   <tr>
      <td><!-- Control here --></td>
   <tr>
  </table>
</div>

 Now the control has a table within it and I have as part of the rendering a div tag that encapsulates that table.  If the user sets the width property of the control to say 1000px I want my control to scroll for 200px because it is contained withing an 800px region.  The problem is it just displays 1000px wide.  Here is the markup being generated for the control:

<div style="overflow:auto;width:inherit;">
   <table cellspacing="0" cellpadding="4" rules="all" border="1" style="font-weight:normal;width:1000px;border-collapse:collapse;">
     ....
   </table>
</div>

 Now to get this to work as I expect I can set the width in the div tag to 800px and it works as expected BUT this is not possible since I'm rendering this in a control  and don't really want to know the details of my parent controls.

I guess my question is, why does the div tag rendered by the control not honor the parent div tag stye of width being 800px.  It seems to be allowed to overrun the parent div tag's boundaries.

RTernier
Asp.Net User
Re: Getting div tag overflow logic to behave1/17/2007 11:49:58 PM

0/0

Do not use a table to get things centered... that's like.. so 90's(in a valley girl accent).   :D

Intsead:

<div style="width:800px;margin-right:auto;margin-left:auto;">

You text here will be centered.

</div>

For scrolling you'll want to set the overflow to auto.  so:

<div style="width:800px;margin-right:auto;margin-left:auto;overflow:auto;">

You text here will be centered.

</div>


The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

My Site | My Examples | My Blog
PeterBrunone
Asp.Net User
Re: Getting div tag overflow logic to behave1/18/2007 6:24:52 PM

0/0

    Are the auto margins the preferred way, as opposed to text-align?  I've always thought it was the latter, but then again I'm no CSS expert.

Cheers,
 


Peter Brunone
MS MVP, ASP.NET
Founder, EasyListBox.com
Do the impossible, and go home early.
CHolt
Asp.Net User
Re: Getting div tag overflow logic to behave1/18/2007 6:34:08 PM

0/0

Ok.  But that didn't really answer my question.  Note: The size is being controlled by the page rendering whereas the scrolling needs to take place within the control with respect to being "contained" within an element that is sized with a explicit width.  The table is just their to show you that the control is being placed within a column of a table that is a control on the page.
RTernier
Asp.Net User
Re: Getting div tag overflow logic to behave1/18/2007 6:41:38 PM

0/0

Text align will align all text to be centered.

If you wanted a block element centered you have to use margins.

Here's a good article on it; http://www.thenoodleincident.com/tutorials/box_lesson/boxes.html


The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

My Site | My Examples | My Blog
RTernier
Asp.Net User
Re: Getting div tag overflow logic to behave1/18/2007 6:47:44 PM

0/0

CHolt:
Ok.  But that didn't really answer my question.  Note: The size is being controlled by the page rendering whereas the scrolling needs to take place within the control with respect to being "contained" within an element that is sized with a explicit width.  The table is just their to show you that the control is being placed within a column of a table that is a control on the page.

If you set the containing (the container) div to a specific width, with overflow:auto; the control that's generated on the inside will be forced to those bounds. So if the control is biggger - the div will scroll - not the control.


The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

My Site | My Examples | My Blog
RTernier
Asp.Net User
Re: Getting div tag overflow logic to behave1/18/2007 6:47:44 PM

0/0

CHolt:
Ok.  But that didn't really answer my question.  Note: The size is being controlled by the page rendering whereas the scrolling needs to take place within the control with respect to being "contained" within an element that is sized with a explicit width.  The table is just their to show you that the control is being placed within a column of a table that is a control on the page.

If you set the containing (the container) div to a specific width, with overflow:auto; the control that's generated on the inside will be forced to those bounds. So if the control is biggger - the div will scroll - not the control.


The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

My Site | My Examples | My Blog
CHolt
Asp.Net User
Re: Getting div tag overflow logic to behave1/18/2007 7:11:21 PM

0/0

I understand that.  Let me ask the question another way.  Why can't a div tag define it's width with respect to another fixed size and have the overflow style work.

Here is an example:

<div style="width: 800px">
  <!--- Some controls here -->
  <div style="width: 100%;overflow: auto;">
    <!-- Controls that have a width over 800px -->
  <div>
</div>

 Why doesn't the inner div tag honor that its width should be 800px because it is contained within another div tag that has its width set to 800px?  The fact that it doesn't I understand.  However, I was wondering if there was a way to have this behavior without doing it this way.

Remember I know in straight html you can fix this by changing the width of the inner div tag to be 800px, BUT the inner div tag is being rendered by a custom control which doesn't have knowledge to set its div tag to a width of 800px because that property isn't set on it.  The 800px is defined in markup on the page.

 One way to solve this is to have two properties on the control: Width and VisibleWidth.

Width is the normal control width, which would be reflected in the custom control grid that it is rendering whereas the VisibleWidth property would be used to set the width of the div tag that contains the grid.  Thereby allowing the scrolling to work as I have described.  However, I was just wondering if there were a way to achieve this without explictly having the control have to be told what to set it's div tag width to.

 Reminder:  The custom control is rendering a grid like:

<div style="overflow:auto;">
  <table>
     ...
  <table>
</div>
 
RTernier
Asp.Net User
Re: Getting div tag overflow logic to behave1/18/2007 11:05:52 PM

0/0

Here are three examples.

 

You'll see that the bottom one behaves a bit differently than the top 2.  I'd also suggest trying this in both FireFox and InternetExplorer 7.

 

CSS is very strict (Which it should be) if you tell it to create a 2x2 box and you want to put a 3x3 box inside of it, you're 3x3x3 box will still be shown - unless you put additoinal rules on the containing box. (Like overflow:auto/Hidden/scroll/visible).

 

<div style="width: 800px">

    <!--- Some controls here -->

    <div style="width: 100%; overflow: auto;">

        Below is my 900px width div

        <div style="width: 900px;">

            hi

        </div>           

    </div>

</div>

 

 <div style="width: 800px;border:dashed 1px red;">

    <!--- Some controls here -->

    <div style="width: 100%; overflow: auto;border:solid 1px blue;">

        Below is my 900px width table

        <table style="width:900px;" border="1">

            <tr>

                <td>

                    This is my cell

                </td>

            </tr>

        </table>                                     

    </div>

</div>

 

<div style="width: 800px;border:dashed 1px red;">

    <!--- Some controls here -->

      Below is my 900px width table

    <div style="width: 100%; overflow: auto;border:solid 1px blue;">

     

        <table style="width:900px;" border="1">

            <tr>

                <td>

                    This is my cell

                </td>

            </tr>

        </table>                                     

    </div>

</div>

---

 

if you do this:

<div style="width: 800px;border:dashed 1px red;">

    <!--- Some controls here -->

      Below is my 900px width table

    <div style="width: 100%; overflow: auto;border:solid 1px blue;">

     

        <img src="http://www.conquerclub.com/maps/Middle_Earth.S.jpg" style="width:1000px;height:800px;" />

    </div>

</div>

You will see that there's a big image inside the div - which scrolls. Seeing you told the image to be 1000x800 - it's going to be that size regardless of the containing div.

 


The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

My Site | My Examples | My Blog
CHolt
Asp.Net User
Re: Getting div tag overflow logic to behave1/19/2007 2:08:55 PM

0/0

Ok, now I'm confused.  Your examples work great!  Exactly like I wanted mine to work.  So why doesn't mine work.  I seem to have the same syntax as your 2nd example.  (See prior post).  I'll need to do a little more digging and see what is wrong with my example
10 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Getting div tag overflow logic to behave - ASP.NET Forums Getting div tag overflow logic to behave. Last post 01-19-2007 9:08 AM by CHolt. 9 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
Twenty Sided » Blog Archive » Tables vs. Div Tags Mar 2, 2007 ... I’m sort of getting my head around the concept of keeping the ... In Firefox/ Opera/Netscape, etc, it behaves correctly and stretches between the two points. ... I’ve found that overflow:hidden on the offending too-wide div seems to patch that ... the business logic layer, and the presentation layer, ...
What's the best way to separate PHP Code and HTML? - Stack Overflow The browser back button behaves itself - no more duplicated actions. ... I prefer than when mixing tag-based markup with PHP. ... I am actually wondering the same thing as I am now getting into Classic ASP. ... It's good practice to separate you data model, your business logic, and your presentation layer. ...
CodeProject: The ScrollableListBox Custom Control for ASP.NET 2.0 ... Jun 13, 2006 ... The Render method firstly renders the start tag of the
HTML element, ... and its horizontal and vertical scrollbars behavior when the
content overflows. ... and makes sure the the control will behave as expected. ..... side logic while the rendering layout will come from the repeater. ...
Preload Images with CSS - CSS - Added Bytes Otherwise, the rollovers will behave badly, like in this example using large images. ... I been using a DIV tag with a display:none as attribute, .... beside the height:0; overflow:hidden; and z-index:-1 (for opera) works fine too to .... too if I tried to please the logic/rendering engines of every single browser. ...
mootools forums / Chaining with conditional logic I've been following the getting started, docs and primer, ... so I can't really use p as the parent tag to select the content. .... #fx-zone { height: auto; overflow: visible; } #body-zone div { display: none; } ... Firefox/Win and IE6/ Win are okay, Opera's not quite behaving itself, and I've left ...
Nabble - jQuery General Discussion - Equal height containers with ... In other words it is not to behave like an “equal height” based on the ... if the content amount is more than the start height (overflow?) then a “…more… ... In an attempt to think through the logic of the goal, here is more written out. ... o Allow the paragraph inside div with class of “tag” to stay displayed ...
Centering Blocks [CSS Working Group Wiki] Sep 15, 2008 ... One thing about the behavior of the “
” tag that does not fit well .... This allows more flexibility for that DIV, as its horizontal position ... Floated items within a “block-align: center” block would behave as usual, .... This follows the same logic as “overflow”, which is shorthand for ...
Starting with Spry - Program - AJAX - Builder AU Jun 18, 2007 ... A dynamic region is declared within a div tag using spry:region, ... The sample code below uses the same logic within the head tag to declare a Spry data set as above. .... they behave more like desktop application user controls than the ... demoDiv{ height: 200px; width: 400px; overflow: hidden; ...
Timeline – WebKit on which we attach the function name property, and add logic to ..... Add
tag. The two classes are stubs for the moment. These tags are required to ..... Updated CachedXBLDocument methods to behave as the other CachedResourceClients. .... Prevent integer overflow when reallocating storage vector for arrays. ...




Search This Site:










using css for tabstrip

'__mytabstrip_state__' is undefined error

tree view control navigation

submit button events not being generated

why does my treeview not seem like a treeview??? sombody can help me?please...

memory leak

treeview & horizontal overflow!

sorting treenodes of a treeview control

tab order when using webcontrol tabstrip

tabs will not change in tab strip

error while add iewebcontrols to toolbox

don't waste your time: ie web controls doesn't work for 1.1

tabstrip clears browser (navigation) history

how to get the treenode by the treenode.id

tabstrip style

tree control images periodically fail to display.

treeview and xml binding, what is wrong??

ie webcontrols not visible in vs.net

can't add microsoft.web.ui.webcontrols to toolbar

problem getting webcontrols into gac

to have no node selected when we load the tree.

why the iewebcontrols do not work?

treeview cache problem?

treeview: non-standard webctrl_client location?

pretty tabs

treeview plus/minus icon

how to resize t.gif, l.gif, i.gif... in treeview

do the iewebcontrols work with asp.net 2?

wierd treeview behaviour after migration

'controls' could not be initialized.

  Privacy | Contact Us
All Times Are GMT