Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

contents of a html cell

I have a html table cell with 2 controls. Currently, the controls are stacked one on top of the other BUT I want them to be side by side. How do i do this
<td class="style20">
                                        <asp:label ID="txtDisplayProductOnline" runat="server" Text=""></asp:label>                                
                                                    <asp:RadioButtonList ID="rdDisplayOnline" runat="server" Height="18px" 
                                                        RepeatDirection="Horizontal" Width="115px">
                                                        <asp:ListItem Selected="True">Yes</asp:ListItem>
                                                        <asp:ListItem>No</asp:ListItem>
                                                    </asp:RadioButtonList>
                                    </td>

Open in new window

0
vbnetcoder
Asked:
vbnetcoder
  • 6
  • 4
  • 2
  • +1
2 Solutions
 
rawinnlnx9Commented:
<table>
<tr>
<td>Control one goes here.</td><td>Control 2 goes here.</td>
</tr>
</table>

Open in new window

0
 
jasonduanCommented:
wrap the controls with <span> tags.
<td class="style20">
   <span><asp:label ID="txtDisplayProductOnline" runat="server" Text=""></asp:label></span>                                
    <span><asp:RadioButtonList ID="rdDisplayOnline" runat="server" Height="18px" 
                                                        RepeatDirection="Horizontal" Width="115px">
          <asp:ListItem Selected="True">Yes</asp:ListItem>
          <asp:ListItem>No</asp:ListItem>
    </asp:RadioButtonList></span>
</td>

Open in new window

0
 
rawinnlnx9Commented:
<tr> = table row
<td> = columns in the table.

Something worth understanding is how <spans> work so that you can have some rows with 5 columns and some rows with 1 column or 2.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
vbnetcoderAuthor Commented:
rawinnlnx9: I forgot to mention that these controls are not going to be visible at the same time.  I want them in exactly the same place if possible.

jasonduan: I tried you solution and it did not make a difference
0
 
dtocciCommented:
you can probably use jasonduan's solution but add some CSS to put the buttons on top of each other.  you need to specify the wrapper td as relatively positioned and each span as absolutely positioned inside of it.  something like this...

<td class="style20" style="position:relative">
   <span style="position:absolute;top:0;left:0;"><asp:label ID="txtDisplayProductOnline" runat="server" Text=""></asp:label></span>                                
    <span style="position:absolute;top:0;left:0;"><asp:RadioButtonList ID="rdDisplayOnline" runat="server" Height="18px" 
                                                        RepeatDirection="Horizontal" Width="115px">
          <asp:ListItem Selected="True">Yes</asp:ListItem>
          <asp:ListItem>No</asp:ListItem>
    </asp:RadioButtonList></span>
</td>

Open in new window

0
 
vbnetcoderAuthor Commented:
dtocci: they are stacked in design  view but not neither show on the screen when the program is run..
0
 
dtocciCommented:
Hmm.  Nothing in that code should make them disappear.  When you view the html source of the resulting page is anything outputting inside the <span> tags?

When you said "these controls are not going to be visible at the same time", do you mean they won't be rendered in the html code at the same time or they'll both be there but only one will be made visible at a time with CSS?  If it's the former, you don't even need the span tags because only one will appear at a time.  If it's the latter, then maybe something you've done in the CSS is making them invisible?
0
 
vbnetcoderAuthor Commented:
In my asp.net code I show them or hide them based on if it is in edit mode or view mode. They will not both be visible at the same time ever....
0
 
vbnetcoderAuthor Commented:
Actually, I noticed they ARE showing but not in the cell but instead in the top right of my screen
0
 
dtocciCommented:
Then it sounds like you can just leave the code the way you had it when you posted the question. They may be stacked in design view but when the page is rendered only one should appear.  It would be impossible for them to be stacked or side-by-side if you only have one or the other rendering.  That should work unless I'm missing something.
0
 
vbnetcoderAuthor Commented:
I want them to appear in the same spot ... currently, the label control appears in on spot when  visible and the radio button control below it...

I will keep working on this.... I am rebuilding the form now it is all messed up
0
 
dtocciCommented:
Just noticed your comment about how they are showing but not in the cell.  That means the <td> container is missing the  style="position:relative".  It needs that so that the position:absolute on the spans will work relative to it, instead of relative to the whole page.

Also, if you use that solution, you may want to set a width for the td cell as it will probably no longer stretch to accommodate what is inside it.  

I'm still not sure why the radio control would appear out of place if it is the only thing being rendered in the cell (without the span wrappers).
0
 
vbnetcoderAuthor Commented:
ty
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now