Hello,
I have something really awkward at work - fighting with CheckBoxList...
How can I define CSS for ListItem in CheckBoxList programmaticall y.
I add CheckBoxList's Items on the fly, something like
dim li as ListItem
li = new ListItem("title ","value");
'' how to define here the CSS for List Item, not CheckBoxList?!? !?!
myCheckBoxList. Items(x).add(li );
Thanks a lot.
--
With the best wishes,
Shaul Feldman 4 6532
There are two approaches I can think of; one is to define an external style selector; it will be tricky since CheckBoxList will
render it's HTML differently depending on the browser -- for uplevel browsers you'll get a <input><label > and you can exploit that
with a CSS selector that looks like:
..CssForListBox label {
color: red;
}
The other approach is to create a <span> around the ListItem Text and attach a style/class to that. See the sample below.
Scott
<%@ Page language="c#" AutoEventWireup ="false" trace="true" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<script language="C#" runat="server">
protected override void OnLoad(EventArg s e)
{
ListItem item = new ListItem();
item.Text = "<span class=\"CheckBo x\">Three</span>";
item.Value = "Three";
this.CheckBoxLi st1.Items.Add(i tem);
}
</script>
<style>
..CheckBoxList
{
font-weight: bold;
font-family: Tahoma, Verdana, 'Times New Roman';
}
..CheckBoxList label
{
color:red;
}
..CheckBox {
color: blue;
}
</style>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:checkboxli st id="CheckBoxLis t1" runat="server" cssclass="Check BoxList">
<asp:listitem value="One">One </asp:listitem>
<asp:listitem value="Two">Two </asp:listitem>
</asp:checkboxlis t>
</form>
</body>
</html>
"Shaul Feldman" <sf******@write me.com> wrote in message news:OX******** ******@TK2MSFTN GP11.phx.gbl... Hello, I have something really awkward at work - fighting with CheckBoxList... How can I define CSS for ListItem in CheckBoxList programmaticall y. I add CheckBoxList's Items on the fly, something like
dim li as ListItem li = new ListItem("title ","value"); '' how to define here the CSS for List Item, not CheckBoxList?!? !?! myCheckBoxList. Items(x).add(li );
Thanks a lot.
-- With the best wishes, Shaul Feldman
Ok,
I think I got the picture...
The question (not quiet ASP.Net, but still) is when you declare
..CheckBoxList label
{
color:red;
}
it means all label instances UNDER elemnets of "CheckBoxLi st" class will be
colored in red, I'm I right? In case I'm wrong, explain it please. Thanks.
Another question why can't be CSS assigned directly to ListItem object?...
It would fit the general concept quiet well.
--
With the best wishes,
Shaul Feldman
"Scott" <no*****@this-is-extra-hotmail.com> wrote in message
news:e2******** ******@TK2MSFTN GP11.phx.gbl... There are two approaches I can think of; one is to define an external
style selector; it will be tricky since CheckBoxList will render it's HTML differently depending on the browser -- for uplevel
browsers you'll get a <input><label > and you can exploit that with a CSS selector that looks like:
.CssForListBox label { color: red; }
The other approach is to create a <span> around the ListItem Text and
attach a style/class to that. See the sample below.
Scott
<%@ Page language="c#" AutoEventWireup ="false" trace="true" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html> <head> <script language="C#" runat="server"> protected override void OnLoad(EventArg s e) { ListItem item = new ListItem(); item.Text = "<span class=\"CheckBo x\">Three</span>"; item.Value = "Three"; this.CheckBoxLi st1.Items.Add(i tem); } </script> <style> .CheckBoxList { font-weight: bold; font-family: Tahoma, Verdana, 'Times New Roman'; } .CheckBoxList label { color:red; }
.CheckBox { color: blue; } </style> </head> <body> <form id="Form1" method="post" runat="server"> <asp:checkboxli st id="CheckBoxLis t1" runat="server"
cssclass="Check BoxList"> <asp:listitem value="One">One </asp:listitem> <asp:listitem value="Two">Two </asp:listitem> </asp:checkboxlis t> </form> </body> </html>
"Shaul Feldman" <sf******@write me.com> wrote in message
news:OX******** ******@TK2MSFTN GP11.phx.gbl... Hello, I have something really awkward at work - fighting with CheckBoxList... How can I define CSS for ListItem in CheckBoxList programmaticall y. I add CheckBoxList's Items on the fly, something like
dim li as ListItem li = new ListItem("title ","value"); '' how to define here the CSS for List Item, not CheckBoxList?!? !?! myCheckBoxList. Items(x).add(li );
Thanks a lot.
-- With the best wishes, Shaul Feldman
..CheckBoxList label {} Means all <label> elements below any element with a class="CheckBox List". So,
<Foobar class="CheckBox List"> ... <label></label></Foobar>
Don't have an answer as to why the individual ListItems can't get a style/class; but if you want a different style for each ListItem the <span style="..."></span> idea will do the same thing.
Scott
"Shaul Feldman" <sf******@write me.com> wrote in message news:ef******** ******@TK2MSFTN GP10.phx.gbl...
Ok,
I think I got the picture...
The question (not quiet ASP.Net, but still) is when you declare
.CheckBoxList label
{
color:red;
}
it means all label instances UNDER elemnets of "CheckBoxLi st" class will be
colored in red, I'm I right? In case I'm wrong, explain it please. Thanks.
Another question why can't be CSS assigned directly to ListItem object?...
It would fit the general concept quiet well.
--
With the best wishes,
Shaul Feldman
"Scott" <no*****@this-is-extra-hotmail.com> wrote in message
news:e2******** ******@TK2MSFTN GP11.phx.gbl... There are two approaches I can think of; one is to define an external
style selector; it will be tricky since CheckBoxList will render it's HTML differently depending on the browser -- for uplevel
browsers you'll get a <input><label > and you can exploit that with a CSS selector that looks like:
.CssForListBox label { color: red; }
The other approach is to create a <span> around the ListItem Text and
attach a style/class to that. See the sample below.
Scott
<%@ Page language="c#" AutoEventWireup ="false" trace="true" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html> <head> <script language="C#" runat="server"> protected override void OnLoad(EventArg s e) { ListItem item = new ListItem(); item.Text = "<span class=\"CheckBo x\">Three</span>"; item.Value = "Three"; this.CheckBoxLi st1.Items.Add(i tem); } </script> <style> .CheckBoxList { font-weight: bold; font-family: Tahoma, Verdana, 'Times New Roman'; } .CheckBoxList label { color:red; }
.CheckBox { color: blue; } </style> </head> <body> <form id="Form1" method="post" runat="server"> <asp:checkboxli st id="CheckBoxLis t1" runat="server"
cssclass="Check BoxList"> <asp:listitem value="One">One </asp:listitem> <asp:listitem value="Two">Two </asp:listitem> </asp:checkboxlis t> </form> </body> </html>
"Shaul Feldman" <sf******@write me.com> wrote in message
news:OX******** ******@TK2MSFTN GP11.phx.gbl... Hello, I have something really awkward at work - fighting with CheckBoxList... How can I define CSS for ListItem in CheckBoxList programmaticall y. I add CheckBoxList's Items on the fly, something like
dim li as ListItem li = new ListItem("title ","value"); '' how to define here the CSS for List Item, not CheckBoxList?!? !?! myCheckBoxList. Items(x).add(li );
Thanks a lot.
-- With the best wishes, Shaul Feldman
Thanks Scott!
Tomorrow I'll try the ".CheckBoxL ist label {} " patent.
--
With the best wishes,
Shaul Feldman
"Scott" <no*****@this-is-extra-hotmail.com> wrote in message news:uy******** *****@tk2msftng p13.phx.gbl...
.CheckBoxList label {} Means all <label> elements below any element with a class="CheckBox List". So,
<Foobar class="CheckBox List"> ... <label></label></Foobar>
Don't have an answer as to why the individual ListItems can't get a style/class; but if you want a different style for each ListItem the <span style="..."></span> idea will do the same thing.
Scott
"Shaul Feldman" <sf******@write me.com> wrote in message news:ef******** ******@TK2MSFTN GP10.phx.gbl...
Ok,
I think I got the picture...
The question (not quiet ASP.Net, but still) is when you declare
.CheckBoxList label
{
color:red;
}
it means all label instances UNDER elemnets of "CheckBoxLi st" class will be
colored in red, I'm I right? In case I'm wrong, explain it please. Thanks.
Another question why can't be CSS assigned directly to ListItem object?...
It would fit the general concept quiet well.
--
With the best wishes,
Shaul Feldman
"Scott" <no*****@this-is-extra-hotmail.com> wrote in message
news:e2******** ******@TK2MSFTN GP11.phx.gbl... There are two approaches I can think of; one is to define an external
style selector; it will be tricky since CheckBoxList will render it's HTML differently depending on the browser -- for uplevel
browsers you'll get a <input><label > and you can exploit that with a CSS selector that looks like:
.CssForListBox label { color: red; }
The other approach is to create a <span> around the ListItem Text and
attach a style/class to that. See the sample below.
Scott
<%@ Page language="c#" AutoEventWireup ="false" trace="true" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html> <head> <script language="C#" runat="server"> protected override void OnLoad(EventArg s e) { ListItem item = new ListItem(); item.Text = "<span class=\"CheckBo x\">Three</span>"; item.Value = "Three"; this.CheckBoxLi st1.Items.Add(i tem); } </script> <style> .CheckBoxList { font-weight: bold; font-family: Tahoma, Verdana, 'Times New Roman'; } .CheckBoxList label { color:red; }
.CheckBox { color: blue; } </style> </head> <body> <form id="Form1" method="post" runat="server"> <asp:checkboxli st id="CheckBoxLis t1" runat="server"
cssclass="Check BoxList"> <asp:listitem value="One">One </asp:listitem> <asp:listitem value="Two">Two </asp:listitem> </asp:checkboxlis t> </form> </body> </html>
"Shaul Feldman" <sf******@write me.com> wrote in message
news:OX******** ******@TK2MSFTN GP11.phx.gbl... Hello, I have something really awkward at work - fighting with CheckBoxList... How can I define CSS for ListItem in CheckBoxList programmaticall y. I add CheckBoxList's Items on the fly, something like
dim li as ListItem li = new ListItem("title ","value"); '' how to define here the CSS for List Item, not CheckBoxList?!? !?! myCheckBoxList. Items(x).add(li );
Thanks a lot.
-- With the best wishes, Shaul Feldman
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robin Day |
last post by:
I run some code on the changed event of checkbox lists. Its quite simple,
nothing more than showing / hiding some other parts of the page.
Using Autopostback and Server side code works fine, but is far too slow,
especially if the users are on modems.
I need to quite simply, add some java code to the onclick event of the input
tags of a checkboxlist.
However... Attributes.Add adds the onclick attribute and code to the
outlying table that...
|
by: dm_dal |
last post by:
Is there a know issue surrounding the CheckBoxList control and it's
viewstate?
When my control is created, it's ListItems are checked as needed, but on a
postback, they loose their Selected status.
David
|
by: Shaul Feldman |
last post by:
Hello,
I have something really awkward at work - fighting with CheckBoxList...
How can I define CSS for ListItem in CheckBoxList programmatically.
I add CheckBoxList's Items on the fly, something like
dim li as ListItem
li = new ListItem("title","value");
'' how to define here the CSS for List Item, not CheckBoxList?!?!?!
myCheckBoxList.Items(x).add(li);
|
by: I am Sam |
last post by:
I keep getting the following error message when I try to iterate through a
CheckBoxList control:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance...
|
by: Amelyan |
last post by:
How can I assign an ID to dynamically generation ListItem that I add to
dynamically generated CheckBoxList or RadioButtonList? I need to identify
the specific ListItem later through Request.Form when user sends back data.
| |
by: Hong Yip |
last post by:
Hi Everyone,
I have an array of checkboxlist. Everything works prefectly fine until I
start working on the "presentation" view. I am not able to "insert" a
checkbox item to a table cell.
Something like that,
TableCell TCell = new TableCell();
|
by: Patrick.O.Ige |
last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected
after doing a postBack.
I have set my CheckBoxlist AutoPostBack="True"
Any ideas what 'm doing wrong?
It seems not to work:(
Thanks
My CheckBoxList in the DataList Below
|
by: CK |
last post by:
Hi All,
I have an asp:CheckBoxList. it is databound to a datatable at runtime;
private void chklstStatuses_DataBinding(object sender, EventArgs e)
{
chklstStatuses.DataSource = BillingInvoiceUtil.GetStatuses();
chklstStatuses.DataTextField = "StatusName";
|
by: clintonG |
last post by:
When selected="true" is declared in the CheckBoxList ListItem FireFox does
not display checked list items. Even more curious is the absence of the
checked="checked" attribute in the source which is present and generated
when the page is requested using IE.
Confusing. Anything I can do?
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |