Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to center Login control on a page?

6 views
Skip to first unread message

dan

unread,
May 5, 2008, 10:43:16 AM5/5/08
to
Hi,

Could someone please let me know how to center a Login control on a page?

Can I use CSS to do that?

Thanks,
Dan


ADN

unread,
May 5, 2008, 11:18:12 AM5/5/08
to
Hi dan,

You could use the CssClass property of the login control to style your
login control and position it:

<asp:Login runat="server" id="myLogin" CssClass="myClass"></asp:Login>

Additionally, you could also wrap your LoginControl in a div and then
position your div on the page wherever you'd like it using a css class

<div class="myClass"><asp:Login runat="server" id="myLogin"></
asp:Login></div>

Rob Eventine

unread,
May 5, 2008, 11:45:33 AM5/5/08
to
Or you could use this;

<center>
Login controls
</center>

it works for me


"dan" <d...@company.com> wrote in message
news:OUnMc4rr...@TK2MSFTNGP02.phx.gbl...

Mark Rae [MVP]

unread,
May 5, 2008, 11:53:50 AM5/5/08
to
"Rob Eventine" <btb...@ntlworld.com> wrote in message
news:xYFTj.8282$WA5....@newsfe6-gui.ntli.net...

[top-posting corrected]

>> Could someone please let me know how to center a Login control on a page?
>>
>> Can I use CSS to do that?
>

> Or you could use this;
>
> <center>
> Login controls
> </center>

The <center> tag has been deprecated for ages and should not be used...

> it works for me

On what browser(s) / platform(s) have you tested it...?


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

dan

unread,
May 5, 2008, 1:01:20 PM5/5/08
to
Thanks for the reply.

I'm still strugling with it. The css applied to the login control seems to
re-arrange controls within the login but does not actually center the
'whole' login control. Would you able to provide a simple example?

Thanks,
Dan

"ADN" <vcua...@gmail.com> wrote in message
news:969ccc3b-b233-45cf...@26g2000hsk.googlegroups.com...

ADN

unread,
May 5, 2008, 1:39:46 PM5/5/08
to
Hey Dan,

If your css class moves all of the controls around, then you could try
the second approach of wrapping the login control in a div like so:

<style>
.myClass{ margin-right: 25%; }
</style>

<div class="myClass"><asp:Login runat="server" id="myLogin"></
asp:Login></div>

I agree with Mark, you shouldn't be using a <center> tag at all. It's
bad practice and it probably isn't browser compatible with all
browsers.

Mike Gleason jr Couturier

unread,
May 6, 2008, 8:58:12 AM5/6/08
to
<div style="width:200px; margin-left:auto; margin-right:auto">
<your login control />
</div>

"dan" <d...@company.com> a écrit dans le message de news:
OUnMc4rr...@TK2MSFTNGP02.phx.gbl...

codereflex

unread,
Jul 21, 2011, 3:42:14 AM7/21/11
to
http://codereflex.net/how-to-place-asp-net-login-control-at-center/

The above link will help you in accomplishing your task :)


>> On Monday, May 05, 2008 11:45 AM Rob Eventine wrote:

>> Or you could use this;
>>
>> <center>
>> Login controls
>> </center>
>>

>> it works for me


>>> On Monday, May 05, 2008 11:53 AM Mark Rae [MVP] wrote:

>>> "Rob Eventine" <btb...@ntlworld.com> wrote in message
>>> news:xYFTj.8282$WA5....@newsfe6-gui.ntli.net...
>>>
>>> [top-posting corrected]
>>>
>>>

>>> The <center> tag has been deprecated for ages and should not be used...
>>>
>>>

>>> On what browser(s) / platform(s) have you tested it...?
>>>
>>>
>>> --
>>> Mark Rae
>>> ASP.NET MVP
>>> http://www.markrae.net


>>>> On Monday, May 05, 2008 1:01 PM dan wrote:

>>>> Thanks for the reply.
>>>>
>>>> I'm still strugling with it. The css applied to the login control seems to
>>>> re-arrange controls within the login but does not actually center the
>>>> 'whole' login control. Would you able to provide a simple example?
>>>>
>>>> Thanks,
>>>> Dan
>>>>
>>>> "ADN" <vcua...@gmail.com> wrote in message
>>>> news:969ccc3b-b233-45cf...@26g2000hsk.googlegroups.com...


>>>>> On Monday, May 05, 2008 10:35 PM ADN wrote:

>>>>> Hi dan,
>>>>>
>>>>> You could use the CssClass property of the login control to style your
>>>>> login control and position it:
>>>>>
>>>>> <asp:Login runat="server" id="myLogin" CssClass="myClass"></asp:Login>
>>>>>
>>>>> Additionally, you could also wrap your LoginControl in a div and then
>>>>> position your div on the page wherever you'd like it using a css class
>>>>>

>>>>> <div class="myClass"><asp:Login runat="server" id="myLogin"></
>>>>> asp:Login></div>

0 new messages