• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 993
  • Last Modified:

How to center or right position a content placeholder control on a web form in Visual Studio

I am using Visual Studio 2008 developing a web page.
I have a content placeholder control with several other controls in it. It is currently left justified when it appears in the web form. .aspx page. It appear to be defaulting to this and has not been set.
Can anyone tell me how to right justify, or how to center the placeholder control? I notice in the properties window for the placeholder control that there is a popup dialog box for the style. I just don't know how to set it to sit in the center of the screen or to make it right justified. The attributes for left and right are in pixels. I have no idea if this is what I need to set and what to set it to.
0
brgdotnet
Asked:
brgdotnet
  • 3
  • 2
2 Solutions
 
brgdotnetAuthor Commented:
I forgot to mention that the placeholder control appears to take up the whole web page. So how to center or right justify all of the controls inside of the placeholder question might be another approach?
0
 
abelCommented:
An asp:PlaceHolder is just that: a placeholder. That means that it does not output any tags or elements on its own, but only its contents. If you want to apply styling to the contents of a placeholder, you have to surround that contents with a div or a table and apply the styling to that. The code below will align the content to the right:


<asp:PlaceHolder runat="server">
    <div style="text-align:right;">
    <asp:Label runat="server" Text="hello" />
    </div>
</asp:PlaceHolder>

Open in new window

0
 
abelCommented:
If you want to have the features of the placeholder and the features of styling in one, you can also choose to use an asp:Panel. Like this:

<asp:Panel runat="server" style="text-align:right;">
     <asp:Label runat="server" Text="hello" />
</asp:Panel>

Open in new window

0
 
brgdotnetAuthor Commented:
Hey guys. Ouch. I believe I mistated my question. But I will give you guys the points and posts again.
0
 
abelCommented:
that's kind of you! ;)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now