Alignment of webcontrols...

C

Coleen

Using Vb.Net v1.1, I have several aspx controls (textboxes, listboxes,
dropdown lists) that I need to align the text within the control...

I've tried:

lst.Attributes.Add("style", "text-align: center;")

in the code-behind, and it does not work. I have also tried setting the
index and doing it on PreRender (like you would for a datagrid) but I get an
error "Item' is not a member of System.EventArgs" on this:

Dim item As ListBox = CType(e.Item, ListBox)

Does anyone have any suggestions for something that OUGHT to be simple?

TIA,

Coleen
 
C

CaffieneRush

I use the Style member of WebControl to style the control rather than
use the Attributes member directly.

Dim currencyBox1 as TextBox
'Align text within currencybox to the right.
currencyBox1.Style.Add("Text-Align", "right")
 
C

Coleen

Thanks! Just a variation of what I was trying, but it DOES work! Thank you
very much!
 
R

Robert W.

This is exactly what I want to do with a 'Month Year' listbox I've just
added. So I used your code as follows:

listBoxDates.Style.Add("Text-Align", "right");

But it didn't change anything. Any idea why?
 

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
473,780
Messages
2,569,610
Members
45,255
Latest member
TopCryptoTwitterChannels

Latest Threads

Top