How to place control on a webbform

T

Tony Johansson

Hello!

I use VS08
Assume that I want to place four label controls and four textbox controls on
a webbform.
So we have four couples each label is associated with a textbox.
Each couple should be placed in each corner of the webbform.

If this would have been a windowform I can just drag the control to the
place that I want.
Now to my question what is the best alternative as far as I see it it's to
use absolute position and drag each
control to the place where I want to have it. ?
Is these better alternatives ?

//Tony
 
A

Arne Vajhøj

I use VS08
Assume that I want to place four label controls and four textbox controls on
a webbform.
So we have four couples each label is associated with a textbox.
Each couple should be placed in each corner of the webbform.

If this would have been a windowform I can just drag the control to the
place that I want.
Now to my question what is the best alternative as far as I see it it's to
use absolute position and drag each
control to the place where I want to have it. ?
Is these better alternatives ?

The concept of corners in a web form is very fuzzy.

In some regards a web page is simply different from
a desktop GUI.

I would drop the idea.

Arne
 
T

Tony Johansson

Arne Vajhøj said:
The concept of corners in a web form is very fuzzy.

In some regards a web page is simply different from
a desktop GUI.

I would drop the idea.

Arne


I just wonder what is the best approach when you want to layout control on
the webbform.
I mean if I use absolute position it's easy to move the control to whatever
I want to have them.
In win form it's just to move them to the place you want them.

In a book I read it says the following.
"If you've used previous versions of Visual Studio you may remember a
feature called grid layout, which
allowed you to position elements with absolute coordinates by dragging them
where you want them.
Although this model seems convenient, it really isn't suited to most web
pages because control can't adjust
their positioning when the web page content changes(or when text is resized
besed on user preferences).
This leads to inflexible layout(such as control that overwrite each other).
That said, Visual Studio 2008 has a
back door way to use grid layout. All you need to do is switch to source
view and add a style attribute that
uses CSS to specify absolute positioning. This attribute will already exist
in any pages you've created with a
previous version of Visual Studio .NET in grid layout mode.
An example.
<asp:Button ID="cmd" style="POSITION: absolute; left: 100px top: 50px;"
runat="server" Text="Floating Button"... />
Once you've made this change, you're free to drag the button around the
window at will. Of course, you
shouldn't go this route just becuse it seems closer to the Windows model.
Most great web pages use abolute
positioning rarely, if at all, because it's just too akward and infexible.
If you do decide to use abolute positioning,
the best idea is to apply it to a container, such as the <div> element. The
<div> element represent a box that is invisible
by default but can optionally have borders, a background fill. and other
formatting. Using absolute positioning, you can then place your <div>
container precisely, but let the content inside use normal flow layout."

So according to the text you should try to avoid absolute positioning but
how should I then position controls.?

//Tony
 
A

andy

"Arne Vajh j" <[email protected]> skrev i meddelandet









I just wonder what is the best approach when you want to layout control on
the webbform.
I mean if I use absolute position it's easy to move the control to whatever
I want to have them.
In win form it's just to move them to the place you want them.

In a book I read it says the following.
"If you've used previous versions of Visual Studio you may remember a
feature called grid layout, which
allowed you to position elements with absolute coordinates by dragging them
where you want them.
Although this model seems convenient, it really isn't suited to most web
pages because control can't adjust
their positioning when the web page content changes(or when text is resized
besed on user preferences).
This leads to inflexible layout(such as control that overwrite each other).
That said, Visual Studio 2008 has a
back door way to use grid layout. All you need to do is switch to source
view and add a style attribute that
uses CSS to specify absolute positioning. This attribute will already exist
in any pages you've created with a
previous version of Visual Studio .NET in grid layout mode.
An example.
<asp:Button ID="cmd" style="POSITION: absolute; left: 100px top: 50px;"
runat="server" Text="Floating Button"... />
Once you've made this change, you're free to drag the button around the
window at will. Of course, you
shouldn't go this route just becuse it seems closer to the Windows model.
Most great web pages use abolute
positioning rarely, if at all, because it's just too akward and infexible..
If you do decide to use abolute positioning,
the best idea is to apply it to a container, such as the <div> element. The
<div> element represent a box that is invisible
by default but can optionally have borders, a background fill. and other
formatting. Using absolute positioning, you can then place your <div>
container precisely, but let the content inside use normal flow layout."

So according to the text you should try to avoid absolute positioning but
how should I then position controls.?

//Tony- Hide quoted text -

- Show quoted text -

asp.net is web.
It's delivered to the client as HTML.
Whilst it is possible to use absolute positioning in HTML, forget it.
Almost nobody uses absolute positioning and almost nobody would hire
anyone who suggested this was the way to layout a HTML web page.

The 2 main layout alternatives are both HTML based.
Table or div.
divs are the way you should lay out the columns and the masthead.
tables are fine for positiioning a bunch of pairs of labels and
textboxes.

There's a shed load of pages out there on the web which explain html
and css.
I strongly recommend you set your asp.net book aside and go read em.

Good luck.
 
A

Arne Vajhøj

I just wonder what is the best approach when you want to layout control on
the webbform.
I mean if I use absolute position it's easy to move the control to whatever
I want to have them.

But it will probably look rather crappy on most browsers.

Remember that you are supporting 4-5 browsers on 4-5 operating
systems on screens with dozens of resolutions.
In win form it's just to move them to the place you want them.

Desktop apps are different from web apps.
In a book I read it says the following.
"If you've used previous versions of Visual Studio you may remember a
feature called grid layout, which
allowed you to position elements with absolute coordinates by dragging them
where you want them.
Although this model seems convenient, it really isn't suited to most web
pages because control can't adjust
their positioning when the web page content changes(or when text is resized
besed on user preferences).
This leads to inflexible layout(such as control that overwrite each other).
That said, Visual Studio 2008 has a
back door way to use grid layout. All you need to do is switch to source
view and add a style attribute that
uses CSS to specify absolute positioning. This attribute will already exist
in any pages you've created with a
previous version of Visual Studio .NET in grid layout mode.
An example.
<asp:Button ID="cmd" style="POSITION: absolute; left: 100px top: 50px;"
runat="server" Text="Floating Button"... />
Once you've made this change, you're free to drag the button around the
window at will. Of course, you
shouldn't go this route just becuse it seems closer to the Windows model.
Most great web pages use abolute
positioning rarely, if at all, because it's just too akward and infexible.

Good advice.
So according to the text you should try to avoid absolute positioning but
how should I then position controls.?

You don't - just output normal HTML pages and leave the detailed
layout to the browsers.

If you don't like that switch to Silverlight!

(or Flash but SL is more relevant in C# context)

Arne
 
A

Arne Vajhøj

asp.net is web.
It's delivered to the client as HTML.
Whilst it is possible to use absolute positioning in HTML, forget it.
Almost nobody uses absolute positioning and almost nobody would hire
anyone who suggested this was the way to layout a HTML web page.

The 2 main layout alternatives are both HTML based.
Table or div.
divs are the way you should lay out the columns and the masthead.
tables are fine for positiioning a bunch of pairs of labels and
textboxes.

There's a shed load of pages out there on the web which explain html
and css.
I strongly recommend you set your asp.net book aside and go read em.

That is very good advice.

HTML, CSS and a bit of JavaScript is a good/necesarry
basis for developing web apps.

Arne
 

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

Top