473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

spacing of controls keeps changeing

BeemerBiker
I am haveing problems getting the positioning of controls set consistently in a UserControl. I can get the control layout correct in design mode.

It look just fine when I drag the control from the solution and drop it onto the page

. Unfortunately it is all wrong when I run the program



I can easily make a change and re-run the program and fix it iteratively. I hate iterative codeing especially when my boss changes what he wants the next time I show him the product.

I suspect I have something set up wrong either in the control or the page I am dropping the user control into. Maybe the whole design is wrong. Anyway, I could use a good reference for how to set up controls so they stay put or maybe someone can look at the following and make a suggestion
Expand|Select|Wrap|Line Numbers
  1. <asp:Panel id="pnl4filter" runat="server" Height="46px" Width="169px" 
  2.     position="absolute" BackColor="#FFFFCC">
  3. <P>
  4.         <asp:TextBox id="txtDateStart" runat="server" Height="16px"
  5.             style="top:-6px; left:6px; z-index: 1; position: relative; width: 76px;"></asp:TextBox>
  6.         &nbsp;            
  7.         <asp:ImageButton ID="idCalendarS" runat="server" 
  8.             style="top:-6px; left:10px; height:16px;  width: 18px; position: relative;" 
  9.             ImageUrl="~/images/SmallCalendar.png" CausesValidation="False" />
  10.         &nbsp;
  11.         <asp:Button ID="cmdGO" runat="server" 
  12.             style="z-index: 1; left: 13px; top: 12px; position: relative; height: 26px; width: 30px;" 
  13.             Text="GO" />
  14.         &nbsp;
  15. ..
  16. <SNIP>
  17. ..
  18. </P>
  19. </asp:Panel>
  20.  
thanks for looking
Mar 21 '09 #1
5 1896
Frinavale
9,735 Expert Mod 8TB
The problem is due to incorrect CSS or a HTML in your User Control.

From the images you've posted I see that the control has a TextBox followed by an ImageButton...then on the next line you have another TextBox followed by another ImageButton....Beside both of these (on the right) there is a button.

The code you've posted does not reflect this and so I cannot tell you where you've gone wrong.

You should have something like (Please note my comments):

Expand|Select|Wrap|Line Numbers
  1. <asp:Panel id="pnl4filter" runat="server" Height="46px" Width="169px" 
  2.     position="absolute" BackColor="#FFFFCC">
  3.  
  4.  
  5. <!--
  6.    Grouping the date selection section into it's own <div> area.
  7.    Setting it's style to float left so that it appears left of the rest of the content..
  8.    which is the button
  9. -->
  10. <asp:Panel id="DateSelectionSection" runat="server" style="float:left">
  11.  
  12. <!--
  13.   Adding the TextBox/ImageButton combination used to gather the
  14.   Start Date
  15. -->
  16.   <asp:Panel id="firstGrouping" runat="server>
  17.         <asp:TextBox id="txtDateStart" runat="server" Height="16px"
  18.             style="top:-6px; left:6px; z-index: 1; position: relative; width: 76px;"></asp:TextBox>
  19.         &nbsp;            
  20.         <asp:ImageButton ID="idCalendarS" runat="server" 
  21.             style="top:-6px; left:10px; height:16px;  width: 18px; position: relative;" 
  22.             ImageUrl="~/images/SmallCalendar.png" CausesValidation="False" />
  23.   </asp:Panel>
  24.  
  25. <!--
  26.   Adding the second TextBox/ImageButton combination used to gather the
  27.   End Date
  28.  
  29.   Please note that since these are in Panels they are rendered as <div>'s
  30.   Because <div> elements are displayed as Blocks, these will appear 
  31.   on top of one another...if you want them beside one another you have to
  32.   float them.
  33. -->
  34.   <asp:Panel id="secondGrouping" runat="server>
  35.         <asp:TextBox id="txtDateEnd" runat="server" Height="16px"
  36.             style="top:-6px; left:6px; z-index: 1; position: relative; width: 76px;"></asp:TextBox>
  37.         &nbsp;            
  38.         <asp:ImageButton ID="idCalendarE" runat="server" 
  39.             style="top:-6px; left:10px; height:16px;  width: 18px; position: relative;" 
  40.             ImageUrl="~/images/SmallCalendar.png" CausesValidation="False" />
  41.   </asp:Panel>
  42. </asp:Panel>
  43.  
  44. <!--
  45.      Hmmm...
  46.      You had a position:relative style for the button,
  47.      This could work but I think you want the button to actually be part of
  48.      this control on the page.
  49.      I've floated it left so that it appears flush next to the above content.
  50.      It would be a good idea to set a Margin style on this as well so that 
  51.      there's a bit of space between the button and the content....
  52.     Or  you could just float the button to the right.....
  53.  
  54. -->
  55.  
  56.         <asp:Button ID="cmdGO" runat="server" 
  57.             style="float:left; margin-left:2px;height: 26px; width: 30px;" 
  58.             Text="GO" />
  59.  
  60. <!--
  61.      Adding a <div> that will make sure that the elements appear 
  62.      within the containing Panel....note that you need both <div> and </div>
  63.      for this to work in all browsers.
  64. -->
  65. <div style="clear:both;"></div>
  66.  
  67. </asp:Panel>
Mar 23 '09 #2
Thanks Frinny!

I actually did not know I could put a panel inside a panel. I thought panels could only go on forms. Also, I see you got rid of that <P> which I thought was required by ascx as VS2008 put it in the page for me. I also was unaware of the existance of "float". I learned a lot.

I changed the DateSelectionPanel to 66% width and 100% height and changed the two inner panels to %50 height and 100% width then floated the button to the right in the %33 remaining space.

This seems to have solved all the alignment problems.


Unaccountably, I cannot set the height of the textbox when using pixels. I wanted the height to match the xx-small font, about "14px", but I found that I had to use "40%" for the height. The "14px" actually worked in the design view, but not at runtime.

So why was the "px" ignored at runtime, but the % worked fine?
Is there an equivalent float for the vertical?

I also plan to use a hovering clickable tooltip (eventually) for the sql filter selections instead of having those start/stop boxes next to the large report buttons. For now, I just want to get it to work and can add the hover stuff later.

thanks again
Mar 23 '09 #3
Frinavale
9,735 Expert Mod 8TB
As far as I know there is no easy way to align things vertically.

You could do a cheat where you set the line-height the same as the height of the <div> (or Panel).....I don't know if this'll work with your button though.

All of your questions are better asked in the CSS forum :)


PS. How did you set the Height and Width of the TextBoxes?
Please post your asp code for this.
Mar 23 '09 #4
drhowarddrfine
7,435 Expert 4TB
Can this be translated into English...um...I mean HTML? :)

Actually, can someone show the generated markup without the asp stuff.
Mar 23 '09 #5
Frinavale
9,735 Expert Mod 8TB
I've created a new thread for the second question.
It can be found here.

@BeemerBiker
An HTML <p> element is supposed to be used to indicate where a paragraph starts and ends. I'm not sure why you thought that this element would be required by a web user control.

Every ASP.NET control is translated into HTML when it is rendered in the browser:
  • TextBox = <input type='text'>
  • Panel = <div>
  • Button = <input type='submit'> or <input type='button'>
  • Label = <span>

Like any HTML, styles for these controls can be set using CSS to arrange the elements the way you'd like them.

A Panel is rendered as a <div>, which indicates a block/group of something...this is why you can place controls (including other Panels) within a Panel.
Mar 23 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Rick DeBay | last post by:
I'm trying to create a layout table, where the spacing between rows varies. I've tried using setting margin-top and border-top for the rows I wan't spaced down from the one above, and I've also...
4
by: fleemo17 | last post by:
Is there a way to tweak the spacing of lines of text (or leading) *specifically* in IE6? I've created a "Quick Search" box in my layout which renders pretty consistently in all the browsers I've...
12
by: Sebastien B. | last post by:
I'm wondering if it's at all possible to have spacing between a table's cells, and only between the cells, not between the outter cells and the table's border. See end of message for an example...
1
by: davebrennan1975 | last post by:
I have a WinForms application that displays multiple choice questions (the choices are actually radio buttons with Appearance=Button). Depending on the question, I may have 3, 4, or 5 choices to...
4
by: Doug Laidlaw | last post by:
At http://www.douglaidlaw.net/boykett/index.html I have a menu of buttons generated by a "self-serve" Web site. As originally supplied, all the buttons were in a block, hard up against each other....
4
by: metoikos | last post by:
I've scoured the web (clumsily, I'm sure) for information on the difficulties I am having, checked my markup in validators, and had a friend with more CSS clue look over it, but I haven't had any...
10
by: phil-news-nospam | last post by:
I have a table with 3 columns in 1 row. I want to increase the spacing _between_ the columns (gutter) _without_ increasing the spacing between those columns and the table itself. Is there a way...
1
by: replyrpatil | last post by:
What I am trying to do: I need to print a compact access report (font 6 size) created using RTF2 program developed by Stephen Lebans to generate a TIF image of custom size (5.5 in x 2.0 in) ...
3
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all It is maybe a stupid question, but I have some trouble with Inheritance. For example: I create a new class with one form. On this form I place on the bottom a Panel and on this Panel...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.