Annoying Attributes

M

Murdoc

Hi all,

Is there any possible way I can tell VS.NET to put the Width parameter for a given control inside
the 'Style' tag, rather than in the <asp:[Contro] /> tag?

For example, VS.NET currently generates the following code:

<asp:ListBox id="SeasonList" runat="server" Height="72px" Width="248px"></asp:ListBox>

for a given ListBox control. My problem is that under just about any browser other than IE, the
width is not taken into account, and the control is resized whenever the Data is modified via
DataBind(). I have found that the following code works under IE and the other browsers, but as soon
as a modification is made to the control in the designer, the STYLE tag is lost.

<asp:ListBox id="SeasonList" runat="server" style="HEIGHT: 72px; WIDTH: 248px;"></asp:ListBox>

Is it possible to have the width/height information made as a Style, rather than as attributes of
the control?

--
Murdoc
; =================================
911: Gov't Sponsored Dial-a-Prayer.
1911: A gun in the hand beats two on the phone.
9-11-01: Four Hijackings, and thousands of deaths, because Gun Banners disarmed the pilots to keep
us safe.
..45ACP: Cure for the Common Criminal.
 
M

Murdoc

Tomas said:
Hi Murdoc,

One option would be to add a style attribute in the codebehind.

SeasonList.Style.Add("width","100px")
SeasonList.Style.Add("height","10px")

If you put this in the Page_Load() of the code behind it would add those
attribute to the Style attribute of the html resulting in

<select style="width:100px,height:10px">
..options
</select>

Damn, that seemed so easy. Why couldn't I think of that?

*plonk*,*plonk*,*plonk*, Ouch!

Thanks, Tomas.
--
Murdoc
... goes off to get his head bandaged ...
; =================================
911: Gov't Sponsored Dial-a-Prayer.
1911: A gun in the hand beats two on the phone.
9-11-01: Four Hijackings, and thousands of deaths, because Gun Banners disarmed the pilots to keep
us safe.
..45ACP: Cure for the Common Criminal.
 

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,813
Messages
2,569,699
Members
45,489
Latest member
SwethaJ

Latest Threads

Top