Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie using css with asp.net

Status
Not open for further replies.

R7Dave

Programmer
Oct 31, 2007
181
US
Hello

I am trying the code below with ASP.NET 2.0.

I am trying to have the width of the dropdownlist1 equal 260 px

Below is my code, could someone point out my error?

Thanks
Dave

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Test_BulletList.aspx.vb" Inherits="ChangeManagement.Test_BulletList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<head runat="server">
<title></title>
<style type = "text/css">
Col2
{width:"260px"
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList
ID="DropDownList1"
CssClass="Col2"
runat="server">
</asp:DropDownList>
</div>
</form>
</body>
</html>
 
You'll have to show us rendered code rather than the ASP.NET code. We can't help you if we don't know what kind of HTML element your ASP control produces.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Hello, thank you, but that didn't work.

I'm not sure what code is needed. ASP.NET uses HTML and Visual Basic in the code behind file. The control gets rendered from the HTML....I don't think I am giving you what is needed. I apologize, I appreciate your help.

Thanks
Dave

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<head><title>

</title>
<style type = "text/css">
Col2
{width:260px;
}
</style>
</head>
<body>
<form name="form1" method="post" action="Test_BulletList.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTI5ODc2OTIxM2RkTslFQm0LZdMtvCkiYhMBjX0MPck=" />
</div>

<div>
<select name="DropDownList1" id="DropDownList1" class="Col2">

</select>
</div>
</form>
</body>
</html>
 
You will NOT be able to successfully style the drop-down to be the desired within all browsers. Some browsers will always ignore a width set and use the width of the content instead.

For this reason, I'd accept that you can't always have what you want, and make all sites work with a scalable select element.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
You still haven't added the period to your Col2 class to make it a class definition:

Code:
  [red]>>.<<[/red]Col2
        {width:260px;
        }
However I agree with Billyray, form elements are rendered according to browser, and Operating System. So it will be hard to get a consistent look across all browsers.
Check out this page:



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thank you - that worked - I will learn about "select" as suggested.

Thanks again
Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top