How to position a user control on a web form

M

moondaddy

I'm trying to create my first user control and its function is to replace
the use of a frames page. I want to position it under the pages header
menus and to the right of the pages contents menus. How can I set the top
and left position of this control?
 
J

Jeff S

Perhaps there is a more sophisticated way, but you can always position the
user control by placing it (declaratively) within a table cell (<TD>).
 
S

Steven Cheng[MSFT]

Hi moondaddy,


Thank you for using MSDN Newsgroup! My name is Steven, and I'll be
assisting you on this issue.
From your description, you add a UserControl onto a webpage, and you'd like
to manually control the position of the UserControl to some certain place
on the page?
If there is anything I misunderstood, please feel free to let me know.

Based on my experience, I think there're several means to help implement
the controls' position on a web page.
1. Using the table to control the page layout and structure. I always think
this the most wonderfully way when dealing with the page's layout. Since
the table can be embed each other and for many hierarchy. You can put a
large table in a page to perform the main layout and then in the large
table's cells, put some small table to perform the detailed layout
operations. As for the problem in our issue, you may try putting the
UserControl in a certain table cell to position it. Also. one of the
advantages of using table to perform layout is the table can adjust itself
in with of height when the page is resized.(table can derived the width and
height from its parent/container control).

2. If you do think it better to use absolute position mode to specify the
UserControl's position, I think you may try use a "<div>" tag. The div
elment can set its "style" attribute to specify its absolute position on a
page. For example:
<div style="LEFT: 300px; WIDTH: 200px; POSITION: absolute; TOP: 300px;
HEIGHT: 200px">
Hello, I am a Div!
</div>

This is a simple div, we set its absolute position as (300,300) on the
page.Then , you can put your UserControl in the div so as to position it.
And also we can specify the "height" and "width" attribute. There are still
many other good features of the "<div>" element, for detailed information,
you can view the following reference in MSDN:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/ref
erence/objects/div.asp


Please check out the preceding suggestions. If you have any questions or
need any further help, please feel free to let me know.



Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
K

Kevin Spencer

In addition to Steven's remarks concerning absolute positioning, if you use
CSS, you can control not only the position of your elements in divs, but the
entire appearance of them. See http://csszengarden.com for examples of what
I'm talking about.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Joined
Nov 6, 2008
Messages
1
Reaction score
0
Do you guys know how to identify the position of controls (X,Y) in ASP.NET with C# (such as textbox, button, checkbox, ...) on a webpage, I dont know how to do it. Please help me, I am really appreciate your support. :veryprou:
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,415
Latest member
PeggyCramp

Latest Threads

Top