468,554 Members | 1,884 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,554 developers. It's quick & easy.

Regarding custom controls - To add align property to label.

Hi all,

I am new to asp.net. So, may be my question may be simple. But I am
feeling hard to achieve this.
I need to create a web custom label control, for which I have to
assign new property called "Align". It should have center,left and
right alignments.
I have created a label with this property and set that to textalign.
But it doesnt have center alignment. How can I get center alignment?

And pls tell me as to how to associate that property to the control.

Thanks in advance..

Mar 15 '07 #1
2 2098
Try using CSS or inline styles to set the alignment. The style in question
is text-align.

If the label fails, as it renders to SPAN (should not, but if), switch to a
Panel control, add a LiteralControl to its Controls property, for the text,
and apply the text-align. Panel renders to DIV, which I am certain can
center align. Try option 1 first.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*********************************************
Think outside the box!
*********************************************
<sw*************@yahoo.co.inwrote in message
news:11**********************@p15g2000hsd.googlegr oups.com...
Hi all,

I am new to asp.net. So, may be my question may be simple. But I am
feeling hard to achieve this.
I need to create a web custom label control, for which I have to
assign new property called "Align". It should have center,left and
right alignments.
I have created a label with this property and set that to textalign.
But it doesnt have center alignment. How can I get center alignment?

And pls tell me as to how to associate that property to the control.

Thanks in advance..
Mar 15 '07 #2
Thanks a lot...
I got it. I am able to achieve it using style.add()

Mar 16 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Sanjay Pais | last post: by
10 posts views Thread by everett | last post: by
4 posts views Thread by Robert | last post: by
1 post views Thread by Robert | last post: by
1 post views Thread by Buddy Ackerman | last post: by
1 post views Thread by Jeremy Chapman | last post: by
reply views Thread by chandrasekhar | last post: by
4 posts views Thread by =?Utf-8?B?UmljaEI=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.