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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any way to do this in asp.net? 3

Status
Not open for further replies.

bburnell

Programmer
Sep 15, 2000
560
US
Does asp.net give you any way to do the following?

Code:
<select>
   <option style="background-color:green; color:white">Pass</option>
   <option style="background-color:red; color:white">Fail</option>
</select>

I am using asp.net 2003 w/ vb.net 2003.

Thanks in advance for the help!
Brett
 
I believe what you want is to use:
<asp:DropDownList>
<asp:ListItem Value="" Selected=""></asp:ListItem>
</asp:DropDownList>


Ordinary Programmer
 
Ok... Here's the deal as I know it.

You "Should" techically be able to do this in the code behind:
Code:
DropDownList1.Items(0).Attributes.Add("style", "background-color:red; color:white")

But... due to a bug, the items' Attributes do NOT get rendered as they should.

If you want to start chasing workarounds for this you can start here:


Senior Software Developer
 
Hi all,

I am in the middle of doing what Mark (ca8msn) suggested. Once I "perfect" what I want, I'll post it for all to see. I guess I was worried about mixing html and aspx together, but that doesn't seem to be a problem.

jbenson, I figured 2.0 would support it. I finally talked them into getting me 2005 last Friday but it will take a few weeks. :)

Mark, your answer from thread 855-1146861 really helped here. Thanks there as well!

Thanks again!
Brett
 
kss444 said:
I believe what you want is to use:
<asp:DropDownList>
<asp:ListItem Value="" Selected=""></asp:ListItem>
</asp:DropDownList>
That doesn't address the posters problem as their issue is to do with styles.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
I guess I was worried about mixing html and aspx together, but that doesn't seem to be a problem.
Yes, it's not a problem (as ASP.NET is in simple terms a wrapper that renders HTML) but the solution depends on what you want to do. For example, if you wanted to manipulate the items server-side then you could go with the option from the thread you linked to, otherwise you could just put the HTML on the page as normal. I guess it's dependant on each situation and there probably isn't one correct answer.



____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
ca8msn wrote:
Yes, it's not a problem (as ASP.NET is in simple terms a wrapper that renders HTML) but the solution depends on what you want to do. For example, if you wanted to manipulate the items server-side then you could go with the option from the thread you linked to, otherwise you could just put the HTML on the page as normal. I guess it's dependant on each situation and there probably isn't one correct answer.
Yeah. That makes sense. I guess my concerns were more towards the manipulation and validation of the data/values in the combobox with the "code behind" in vb.net. Since I have to retrieve the values and add them to a SQL Server database, but so far, that doesn't seem to be a problem.

Even though I've been coding in .net since 2001, I'm far from an expert. I really appreciate the help and not making me feel like an idiot. LOL. I'll keep you posted on the final design. Thanks again!

Brett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top