473,387 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Class not working for textbox.

I cannot seem to get the asp:textbox to use classes. Style works fine. I
am trying to set the textbox to act like a label in some instance so it
doesn't have a border, readonly and the background is grey.

I have a class set as:

..table2Label{
border-style:none;
background-color:#F6F6F6;
}

I have a textbox:

<asp:textbox id="applicantID" class="table2label"
TextMode="SingleLine" Columns="32" runat="server" />

This doesn't seem to work.

If I do this:

<asp:textbox id="applicantID" Style=" border-style:none;
background-color:#F6F6F6;" TextMode="SingleLine" Columns="32" runat="server"
/>

This works perfectly.

Why doesn't the class?

Thanks,

Tom.
Nov 19 '05 #1
8 3426
tshad wrote:
I cannot seem to get the asp:textbox to use classes. Style works
fine. I am trying to set the textbox to act like a label in some
instance so it doesn't have a border, readonly and the background is
grey.

I have a class set as:

.table2Label{
border-style:none;
background-color:#F6F6F6;
}
I have a textbox:
<asp:textbox id="applicantID" class="table2label"
TextMode="SingleLine" Columns="32" runat="server" />

This doesn't seem to work.


Tom,
You are setting the wrong atttribute.
For Web Server controls, use CSSClass property.

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
Nov 19 '05 #2
"Carl Prothman [MVP]" <ca****@spamcop.net> wrote in message
news:OD****************@TK2MSFTNGP10.phx.gbl...
tshad wrote:
I cannot seem to get the asp:textbox to use classes. Style works
fine. I am trying to set the textbox to act like a label in some
instance so it doesn't have a border, readonly and the background is
grey.

I have a class set as:

.table2Label{
border-style:none;
background-color:#F6F6F6;
}
I have a textbox:
<asp:textbox id="applicantID" class="table2label"
TextMode="SingleLine" Columns="32" runat="server" />

This doesn't seem to work.

Tom,
You are setting the wrong atttribute.
For Web Server controls, use CSSClass property.


I did try that also and it still doesn't seem to work - I am using Mozilla.

I also changed the name to .text2label as I misnamed it.

<asp:textbox id="applicantID" CSSClass="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

and

..textbox2Label{
border-style:none;
background-color:#F6F6F6;
}

I also tried this at runtime and it doesn't work there either.

Tom.
--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP

Nov 19 '05 #3
There's nothing wrong with what you are doing. you can either use class or
CssClass (class isn't a recognize proprety so it simply gets rendered as-is
as an html attribute). Probably better to use cssClass so you can program
against it easier..but that isn't your issue.

I've experienced extremely finiky behaviour from firefox with respect to
applying styles to textboxes...simple things like extra spaces causing
problems...I imagine you are running into the same problem (and I imagine it
isn't with firefox but something we are doing). Simply try rewriting the
style as:
..table2Label{border-style:none;background-color:#F6F6F6;}

and make sure nothing is indented ...

Lemme know.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Od****************@TK2MSFTNGP15.phx.gbl...
"Carl Prothman [MVP]" <ca****@spamcop.net> wrote in message
news:OD****************@TK2MSFTNGP10.phx.gbl...
tshad wrote:
I cannot seem to get the asp:textbox to use classes. Style works
fine. I am trying to set the textbox to act like a label in some
instance so it doesn't have a border, readonly and the background is
grey.

I have a class set as:

.table2Label{
border-style:none;
background-color:#F6F6F6;
}
I have a textbox:
<asp:textbox id="applicantID" class="table2label"
TextMode="SingleLine" Columns="32" runat="server" />

This doesn't seem to work.

Tom,
You are setting the wrong atttribute.
For Web Server controls, use CSSClass property.


I did try that also and it still doesn't seem to work - I am using

Mozilla.
I also changed the name to .text2label as I misnamed it.

<asp:textbox id="applicantID" CSSClass="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

and

.textbox2Label{
border-style:none;
background-color:#F6F6F6;
}

I also tried this at runtime and it doesn't work there either.

Tom.

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP


Nov 19 '05 #4
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OR****************@TK2MSFTNGP11.phx.gbl...
There's nothing wrong with what you are doing. you can either use class
or
CssClass (class isn't a recognize proprety so it simply gets rendered
as-is
as an html attribute). Probably better to use cssClass so you can program
against it easier..but that isn't your issue.

I've experienced extremely finiky behaviour from firefox with respect to
applying styles to textboxes...simple things like extra spaces causing
problems...I imagine you are running into the same problem (and I imagine
it
isn't with firefox but something we are doing). Simply try rewriting
the
style as:
.table2Label{border-style:none;background-color:#F6F6F6;}

and make sure nothing is indented ...
Nope.

I also tried IE and Netscape and they don't work either.

Does this statement look right?

<asp:textbox id="applicantID" Class="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

Here is the CSS file from the beginning to just after the text2label class.
***********************************************
body {
margin:0;
padding:0;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
th {
background-color:#2FABAD;
color:white;
text-decoration: none;
border-style:none;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
..dataGrid {
background-color:#2FABAD;
color:white;
border-style:none;
font-family: Verdana, Arial, Helvetica, sans-serif;
}

..dataGrid a:visited {color:#FFFFFF;font-weight:bold;
}
..dataGrid a:link {color:#FFFFFF;font-weight:bold;
}
..dataGrid a:active {color:#FFFFFF;font-weight:bold;
}

..table2Label{border-style:none;background-color:#F6F6F6;}

..console{
background-color:#2FABAD;
color:white;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size:12;
}
************************************************** *****

Here it is rendered in IE (looks right)

************************************************** *******************
<tr valign="baseline">
<td width="160" align="right" nowrap class="BodyText">Applicant
ID:</td>
<td >
<input name="applicantID" type="text" value="1000" size="32"
readonly="readonly" id="applicantID" Class="textbox2Label" />
</td>
</tr>
************************************************** **************************

Here it is in Mozilla (also appears correct):
************************************************** *************************
<tr valign="baseline">
<td width="160" align="right" nowrap class="BodyText">Applicant
ID:</td>
<td >
<input name="applicantID" type="text" value="1000" size="32"
readonly="readonly" id="applicantID" Class="textbox2Label" />
</td>
</tr>
************************************************** **************************

This is what drives me crazy. I spend hours or days trying to get something
to work that should work. I have spent the whole day on this and can't seem
to get it to work.

I think I am just going to create an identical page and change all the
textboxes to labels as I can't spend too much more time on this.

Thanks,

Tom

Lemme know.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Od****************@TK2MSFTNGP15.phx.gbl...
"Carl Prothman [MVP]" <ca****@spamcop.net> wrote in message
news:OD****************@TK2MSFTNGP10.phx.gbl...
> tshad wrote:
>> I cannot seem to get the asp:textbox to use classes. Style works
>> fine. I am trying to set the textbox to act like a label in some
>> instance so it doesn't have a border, readonly and the background is
>> grey.
>>
>> I have a class set as:
>>
>> .table2Label{
>> border-style:none;
>> background-color:#F6F6F6;
>> }
>> I have a textbox:
>> <asp:textbox id="applicantID" class="table2label"
>> TextMode="SingleLine" Columns="32" runat="server" />
>>
>> This doesn't seem to work.
>>
>
> Tom,
> You are setting the wrong atttribute.
> For Web Server controls, use CSSClass property.


I did try that also and it still doesn't seem to work - I am using

Mozilla.

I also changed the name to .text2label as I misnamed it.

<asp:textbox id="applicantID" CSSClass="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

and

.textbox2Label{
border-style:none;
background-color:#F6F6F6;
}

I also tried this at runtime and it doesn't work there either.

Tom.
>
> --
>
> Thanks,
> Carl Prothman
> Microsoft ASP.NET MVP
>
>



Nov 19 '05 #5
Not sure if this was intentional, but in your code you have;

<asp:textbox id="applicantID" Class="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

And in your CSS you have;

..table2Label{border-style:none;background-color:#F6F6F6;}

The class names don't match, if I'm reading in the correct place.

Also double-check to make certain the CSS file is actually referenced in
your page, that would bite you as well.

Do a view-source on the resulting code to see how the textbox is rendering,
to make certain everything matches up as you intended.

All else looks spot-on.

/// M
"tshad" <ts**********@ftsolutions.com> wrote in message
news:#V**************@tk2msftngp13.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OR****************@TK2MSFTNGP11.phx.gbl...
There's nothing wrong with what you are doing. you can either use class
or
CssClass (class isn't a recognize proprety so it simply gets rendered
as-is
as an html attribute). Probably better to use cssClass so you can program against it easier..but that isn't your issue.

I've experienced extremely finiky behaviour from firefox with respect to
applying styles to textboxes...simple things like extra spaces causing
problems...I imagine you are running into the same problem (and I imagine it
isn't with firefox but something we are doing). Simply try rewriting
the
style as:
.table2Label{border-style:none;background-color:#F6F6F6;}

and make sure nothing is indented ...
Nope.

I also tried IE and Netscape and they don't work either.

Does this statement look right?

<asp:textbox id="applicantID" Class="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

Here is the CSS file from the beginning to just after the text2label

class. ***********************************************
body {
margin:0;
padding:0;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
th {
background-color:#2FABAD;
color:white;
text-decoration: none;
border-style:none;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.dataGrid {
background-color:#2FABAD;
color:white;
border-style:none;
font-family: Verdana, Arial, Helvetica, sans-serif;
}

.dataGrid a:visited {color:#FFFFFF;font-weight:bold;
}
.dataGrid a:link {color:#FFFFFF;font-weight:bold;
}
.dataGrid a:active {color:#FFFFFF;font-weight:bold;
}

.table2Label{border-style:none;background-color:#F6F6F6;}

.console{
background-color:#2FABAD;
color:white;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size:12;
}
************************************************** *****

Here it is rendered in IE (looks right)

************************************************** *******************
<tr valign="baseline">
<td width="160" align="right" nowrap class="BodyText">Applicant
ID:</td>
<td >
<input name="applicantID" type="text" value="1000" size="32"
readonly="readonly" id="applicantID" Class="textbox2Label" />
</td>
</tr>
************************************************** **************************
Here it is in Mozilla (also appears correct):
************************************************** ************************* <tr valign="baseline">
<td width="160" align="right" nowrap class="BodyText">Applicant
ID:</td>
<td >
<input name="applicantID" type="text" value="1000" size="32"
readonly="readonly" id="applicantID" Class="textbox2Label" />
</td>
</tr>
************************************************** **************************
This is what drives me crazy. I spend hours or days trying to get something to work that should work. I have spent the whole day on this and can't seem to get it to work.

I think I am just going to create an identical page and change all the
textboxes to labels as I can't spend too much more time on this.

Thanks,

Tom

Lemme know.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Od****************@TK2MSFTNGP15.phx.gbl...
"Carl Prothman [MVP]" <ca****@spamcop.net> wrote in message
news:OD****************@TK2MSFTNGP10.phx.gbl...
> tshad wrote:
>> I cannot seem to get the asp:textbox to use classes. Style works
>> fine. I am trying to set the textbox to act like a label in some
>> instance so it doesn't have a border, readonly and the background is
>> grey.
>>
>> I have a class set as:
>>
>> .table2Label{
>> border-style:none;
>> background-color:#F6F6F6;
>> }
>> I have a textbox:
>> <asp:textbox id="applicantID" class="table2label"
>> TextMode="SingleLine" Columns="32" runat="server" />
>>
>> This doesn't seem to work.
>>
>
> Tom,
> You are setting the wrong atttribute.
> For Web Server controls, use CSSClass property.

I did try that also and it still doesn't seem to work - I am using

Mozilla.

I also changed the name to .text2label as I misnamed it.

<asp:textbox id="applicantID" CSSClass="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

and

.textbox2Label{
border-style:none;
background-color:#F6F6F6;
}

I also tried this at runtime and it doesn't work there either.

Tom.
>
> --
>
> Thanks,
> Carl Prothman
> Microsoft ASP.NET MVP
>
>



Nov 19 '05 #6
"MWells" <outbound__at_sygnal.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...
Not sure if this was intentional, but in your code you have;

<asp:textbox id="applicantID" Class="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

And in your CSS you have;

.table2Label{border-style:none;background-color:#F6F6F6;}
You're right. I just changed the names to better match what I was trying to
do and forgot to rename it in the css page. After I did, it didn't help.

The class names don't match, if I'm reading in the correct place.

Also double-check to make certain the CSS file is actually referenced in
your page, that would bite you as well.
I did. If I comment out the line "<link href="staffing.css"
rel="stylesheet" type="text/css">", none of my styles work - so I know it is
being loaded.

Thanks,

Tom
Do a view-source on the resulting code to see how the textbox is
rendering,
to make certain everything matches up as you intended.

All else looks spot-on.

/// M
"tshad" <ts**********@ftsolutions.com> wrote in message
news:#V**************@tk2msftngp13.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OR****************@TK2MSFTNGP11.phx.gbl...
> There's nothing wrong with what you are doing. you can either use
> class
> or
> CssClass (class isn't a recognize proprety so it simply gets rendered
> as-is
> as an html attribute). Probably better to use cssClass so you can program > against it easier..but that isn't your issue.
>
> I've experienced extremely finiky behaviour from firefox with respect
> to
> applying styles to textboxes...simple things like extra spaces causing
> problems...I imagine you are running into the same problem (and I imagine > it
> isn't with firefox but something we are doing). Simply try rewriting
> the
> style as:
> .table2Label{border-style:none;background-color:#F6F6F6;}
>
> and make sure nothing is indented ...


Nope.

I also tried IE and Netscape and they don't work either.

Does this statement look right?

<asp:textbox id="applicantID" Class="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

Here is the CSS file from the beginning to just after the text2label

class.
***********************************************
body {
margin:0;
padding:0;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
th {
background-color:#2FABAD;
color:white;
text-decoration: none;
border-style:none;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.dataGrid {
background-color:#2FABAD;
color:white;
border-style:none;
font-family: Verdana, Arial, Helvetica, sans-serif;
}

.dataGrid a:visited {color:#FFFFFF;font-weight:bold;
}
.dataGrid a:link {color:#FFFFFF;font-weight:bold;
}
.dataGrid a:active {color:#FFFFFF;font-weight:bold;
}

.table2Label{border-style:none;background-color:#F6F6F6;}

.console{
background-color:#2FABAD;
color:white;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size:12;
}
************************************************** *****

Here it is rendered in IE (looks right)

************************************************** *******************
<tr valign="baseline">
<td width="160" align="right" nowrap class="BodyText">Applicant
ID:</td>
<td >
<input name="applicantID" type="text" value="1000" size="32"
readonly="readonly" id="applicantID" Class="textbox2Label" />
</td>
</tr>

************************************************** **************************

Here it is in Mozilla (also appears correct):

************************************************** *************************
<tr valign="baseline">
<td width="160" align="right" nowrap class="BodyText">Applicant
ID:</td>
<td >
<input name="applicantID" type="text" value="1000" size="32"
readonly="readonly" id="applicantID" Class="textbox2Label" />
</td>
</tr>

************************************************** **************************

This is what drives me crazy. I spend hours or days trying to get

something
to work that should work. I have spent the whole day on this and can't

seem
to get it to work.

I think I am just going to create an identical page and change all the
textboxes to labels as I can't spend too much more time on this.

Thanks,

Tom
>
> Lemme know.
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "tshad" <ts**********@ftsolutions.com> wrote in message
> news:Od****************@TK2MSFTNGP15.phx.gbl...
>> "Carl Prothman [MVP]" <ca****@spamcop.net> wrote in message
>> news:OD****************@TK2MSFTNGP10.phx.gbl...
>> > tshad wrote:
>> >> I cannot seem to get the asp:textbox to use classes. Style works
>> >> fine. I am trying to set the textbox to act like a label in some
>> >> instance so it doesn't have a border, readonly and the background
>> >> is
>> >> grey.
>> >>
>> >> I have a class set as:
>> >>
>> >> .table2Label{
>> >> border-style:none;
>> >> background-color:#F6F6F6;
>> >> }
>> >> I have a textbox:
>> >> <asp:textbox id="applicantID" class="table2label"
>> >> TextMode="SingleLine" Columns="32" runat="server" />
>> >>
>> >> This doesn't seem to work.
>> >>
>> >
>> > Tom,
>> > You are setting the wrong atttribute.
>> > For Web Server controls, use CSSClass property.
>>
>> I did try that also and it still doesn't seem to work - I am using
> Mozilla.
>>
>> I also changed the name to .text2label as I misnamed it.
>>
>> <asp:textbox id="applicantID" CSSClass="textbox2Label"
>> TextMode="SingleLine" Columns="32" runat="server" />
>>
>> and
>>
>> .textbox2Label{
>> border-style:none;
>> background-color:#F6F6F6;
>> }
>>
>> I also tried this at runtime and it doesn't work there either.
>>
>> Tom.
>> >
>> > --
>> >
>> > Thanks,
>> > Carl Prothman
>> > Microsoft ASP.NET MVP
>> >
>> >
>>
>>
>
>



Nov 19 '05 #7
OK.

I seem to have found the problem. I was able to see it when I viewed the
source and tried to run it as a straight HTM file.

I had my link to the css file in there twice. This doesn't cause a problem
in the htm file which worked fine with the text2label class.

But for some reason, having the 2 links in the aspx file, caused it a
problem.

The reason it was in there twice, was because I had taken all the headers
and footers and put them in include files so all my pages would be the same.
I inadvertantly put the link in the include file and forgot to delete it
from my page (so they were there twice). This shouldn't have caused a
problem (as they obviously are identical and worked fine that way in the htm
file) - but it did.

The problem is now is what if you use 2 different css files - will that
cause a problem in asp.net.

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uC****************@TK2MSFTNGP12.phx.gbl...
"MWells" <outbound__at_sygnal.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...
Not sure if this was intentional, but in your code you have;

<asp:textbox id="applicantID" Class="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

And in your CSS you have;

.table2Label{border-style:none;background-color:#F6F6F6;}


You're right. I just changed the names to better match what I was trying
to do and forgot to rename it in the css page. After I did, it didn't
help.

The class names don't match, if I'm reading in the correct place.

Also double-check to make certain the CSS file is actually referenced in
your page, that would bite you as well.


I did. If I comment out the line "<link href="staffing.css"
rel="stylesheet" type="text/css">", none of my styles work - so I know it
is being loaded.

Thanks,

Tom

Do a view-source on the resulting code to see how the textbox is
rendering,
to make certain everything matches up as you intended.

All else looks spot-on.

/// M
"tshad" <ts**********@ftsolutions.com> wrote in message
news:#V**************@tk2msftngp13.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OR****************@TK2MSFTNGP11.phx.gbl...
> There's nothing wrong with what you are doing. you can either use
> class
> or
> CssClass (class isn't a recognize proprety so it simply gets rendered
> as-is
> as an html attribute). Probably better to use cssClass so you can

program
> against it easier..but that isn't your issue.
>
> I've experienced extremely finiky behaviour from firefox with respect
> to
> applying styles to textboxes...simple things like extra spaces causing
> problems...I imagine you are running into the same problem (and I

imagine
> it
> isn't with firefox but something we are doing). Simply try
> rewriting
> the
> style as:
> .table2Label{border-style:none;background-color:#F6F6F6;}
>
> and make sure nothing is indented ...

Nope.

I also tried IE and Netscape and they don't work either.

Does this statement look right?

<asp:textbox id="applicantID" Class="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

Here is the CSS file from the beginning to just after the text2label

class.
***********************************************
body {
margin:0;
padding:0;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
th {
background-color:#2FABAD;
color:white;
text-decoration: none;
border-style:none;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.dataGrid {
background-color:#2FABAD;
color:white;
border-style:none;
font-family: Verdana, Arial, Helvetica, sans-serif;
}

.dataGrid a:visited {color:#FFFFFF;font-weight:bold;
}
.dataGrid a:link {color:#FFFFFF;font-weight:bold;
}
.dataGrid a:active {color:#FFFFFF;font-weight:bold;
}

.table2Label{border-style:none;background-color:#F6F6F6;}

.console{
background-color:#2FABAD;
color:white;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size:12;
}
************************************************** *****

Here it is rendered in IE (looks right)

************************************************** *******************
<tr valign="baseline">
<td width="160" align="right" nowrap class="BodyText">Applicant
ID:</td>
<td >
<input name="applicantID" type="text" value="1000" size="32"
readonly="readonly" id="applicantID" Class="textbox2Label" />
</td>
</tr>

************************************************** **************************

Here it is in Mozilla (also appears correct):

************************************************** *************************
<tr valign="baseline">
<td width="160" align="right" nowrap class="BodyText">Applicant
ID:</td>
<td >
<input name="applicantID" type="text" value="1000" size="32"
readonly="readonly" id="applicantID" Class="textbox2Label" />
</td>
</tr>

************************************************** **************************

This is what drives me crazy. I spend hours or days trying to get

something
to work that should work. I have spent the whole day on this and can't

seem
to get it to work.

I think I am just going to create an identical page and change all the
textboxes to labels as I can't spend too much more time on this.

Thanks,

Tom

>
> Lemme know.
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "tshad" <ts**********@ftsolutions.com> wrote in message
> news:Od****************@TK2MSFTNGP15.phx.gbl...
>> "Carl Prothman [MVP]" <ca****@spamcop.net> wrote in message
>> news:OD****************@TK2MSFTNGP10.phx.gbl...
>> > tshad wrote:
>> >> I cannot seem to get the asp:textbox to use classes. Style works
>> >> fine. I am trying to set the textbox to act like a label in some
>> >> instance so it doesn't have a border, readonly and the background
>> >> is
>> >> grey.
>> >>
>> >> I have a class set as:
>> >>
>> >> .table2Label{
>> >> border-style:none;
>> >> background-color:#F6F6F6;
>> >> }
>> >> I have a textbox:
>> >> <asp:textbox id="applicantID" class="table2label"
>> >> TextMode="SingleLine" Columns="32" runat="server" />
>> >>
>> >> This doesn't seem to work.
>> >>
>> >
>> > Tom,
>> > You are setting the wrong atttribute.
>> > For Web Server controls, use CSSClass property.
>>
>> I did try that also and it still doesn't seem to work - I am using
> Mozilla.
>>
>> I also changed the name to .text2label as I misnamed it.
>>
>> <asp:textbox id="applicantID" CSSClass="textbox2Label"
>> TextMode="SingleLine" Columns="32" runat="server" />
>>
>> and
>>
>> .textbox2Label{
>> border-style:none;
>> background-color:#F6F6F6;
>> }
>>
>> I also tried this at runtime and it doesn't work there either.
>>
>> Tom.
>> >
>> > --
>> >
>> > Thanks,
>> > Carl Prothman
>> > Microsoft ASP.NET MVP
>> >
>> >
>>
>>
>
>



Nov 19 '05 #8
That's an interesting scenario; but the behavior shouldn't be any different
under .NET.

Remember that ASP.NET's primary function is to render HTML from nice, neat,
manageable components. At the end of the day, it's all about the HTML that
arrives at the browser.

ASP.NET really knows nothing about CSS files; it's just a <LINK> tag in your
header. Only things with a runat=server attribute are important to ASP.NET,
so all of the pure HTML parts of your page (including your <LINK> tags)
should pass through ASP.NET unscathed.

It sounds like your problem is solved, but if you're pursuing this
academically, here's an interesting test;

Take your ASP.NET page, execute it, view the source and save it as
TEST1.HTM. Then duplicate that HTM file and rename it TEST1.ASPX. Since
it's already rendered, there's no code to execute, and nothing for ASP.NET
to do... but the request will still pass through the .NET infrastructure.

Afaik, accessing both TEST1 files from your browser should give identical
results.
"tshad" <ts**********@ftsolutions.com> wrote in message
news:eR**************@TK2MSFTNGP10.phx.gbl...
OK.

I seem to have found the problem. I was able to see it when I viewed the
source and tried to run it as a straight HTM file.

I had my link to the css file in there twice. This doesn't cause a problem in the htm file which worked fine with the text2label class.

But for some reason, having the 2 links in the aspx file, caused it a
problem.

The reason it was in there twice, was because I had taken all the headers
and footers and put them in include files so all my pages would be the same. I inadvertantly put the link in the include file and forgot to delete it
from my page (so they were there twice). This shouldn't have caused a
problem (as they obviously are identical and worked fine that way in the htm file) - but it did.

The problem is now is what if you use 2 different css files - will that
cause a problem in asp.net.

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uC****************@TK2MSFTNGP12.phx.gbl...
"MWells" <outbound__at_sygnal.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...
Not sure if this was intentional, but in your code you have;

<asp:textbox id="applicantID" Class="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

And in your CSS you have;

.table2Label{border-style:none;background-color:#F6F6F6;}


You're right. I just changed the names to better match what I was trying to do and forgot to rename it in the css page. After I did, it didn't
help.

The class names don't match, if I'm reading in the correct place.

Also double-check to make certain the CSS file is actually referenced in your page, that would bite you as well.


I did. If I comment out the line "<link href="staffing.css"
rel="stylesheet" type="text/css">", none of my styles work - so I know it is being loaded.

Thanks,

Tom

Do a view-source on the resulting code to see how the textbox is
rendering,
to make certain everything matches up as you intended.

All else looks spot-on.

/// M
"tshad" <ts**********@ftsolutions.com> wrote in message
news:#V**************@tk2msftngp13.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:OR****************@TK2MSFTNGP11.phx.gbl...
> There's nothing wrong with what you are doing. you can either use
> class
> or
> CssClass (class isn't a recognize proprety so it simply gets rendered > as-is
> as an html attribute). Probably better to use cssClass so you can
program
> against it easier..but that isn't your issue.
>
> I've experienced extremely finiky behaviour from firefox with respect > to
> applying styles to textboxes...simple things like extra spaces causing > problems...I imagine you are running into the same problem (and I
imagine
> it
> isn't with firefox but something we are doing). Simply try
> rewriting
> the
> style as:
> .table2Label{border-style:none;background-color:#F6F6F6;}
>
> and make sure nothing is indented ...

Nope.

I also tried IE and Netscape and they don't work either.

Does this statement look right?

<asp:textbox id="applicantID" Class="textbox2Label"
TextMode="SingleLine" Columns="32" runat="server" />

Here is the CSS file from the beginning to just after the text2label
class.
***********************************************
body {
margin:0;
padding:0;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
th {
background-color:#2FABAD;
color:white;
text-decoration: none;
border-style:none;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.dataGrid {
background-color:#2FABAD;
color:white;
border-style:none;
font-family: Verdana, Arial, Helvetica, sans-serif;
}

.dataGrid a:visited {color:#FFFFFF;font-weight:bold;
}
.dataGrid a:link {color:#FFFFFF;font-weight:bold;
}
.dataGrid a:active {color:#FFFFFF;font-weight:bold;
}

.table2Label{border-style:none;background-color:#F6F6F6;}

.console{
background-color:#2FABAD;
color:white;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size:12;
}
************************************************** *****

Here it is rendered in IE (looks right)

************************************************** *******************
<tr valign="baseline">
<td width="160" align="right" nowrap class="BodyText">Applicant
ID:</td>
<td >
<input name="applicantID" type="text" value="1000" size="32"
readonly="readonly" id="applicantID" Class="textbox2Label" />
</td>
</tr>

************************************************** **************************
Here it is in Mozilla (also appears correct):

************************************************** ************************* <tr valign="baseline">
<td width="160" align="right" nowrap class="BodyText">Applicant
ID:</td>
<td >
<input name="applicantID" type="text" value="1000" size="32"
readonly="readonly" id="applicantID" Class="textbox2Label" />
</td>
</tr>

************************************************** **************************
This is what drives me crazy. I spend hours or days trying to get
something
to work that should work. I have spent the whole day on this and can't seem
to get it to work.

I think I am just going to create an identical page and change all the
textboxes to labels as I can't spend too much more time on this.

Thanks,

Tom

>
> Lemme know.
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "tshad" <ts**********@ftsolutions.com> wrote in message
> news:Od****************@TK2MSFTNGP15.phx.gbl...
>> "Carl Prothman [MVP]" <ca****@spamcop.net> wrote in message
>> news:OD****************@TK2MSFTNGP10.phx.gbl...
>> > tshad wrote:
>> >> I cannot seem to get the asp:textbox to use classes. Style works >> >> fine. I am trying to set the textbox to act like a label in some >> >> instance so it doesn't have a border, readonly and the background >> >> is
>> >> grey.
>> >>
>> >> I have a class set as:
>> >>
>> >> .table2Label{
>> >> border-style:none;
>> >> background-color:#F6F6F6;
>> >> }
>> >> I have a textbox:
>> >> <asp:textbox id="applicantID" class="table2label"
>> >> TextMode="SingleLine" Columns="32" runat="server" />
>> >>
>> >> This doesn't seem to work.
>> >>
>> >
>> > Tom,
>> > You are setting the wrong atttribute.
>> > For Web Server controls, use CSSClass property.
>>
>> I did try that also and it still doesn't seem to work - I am using
> Mozilla.
>>
>> I also changed the name to .text2label as I misnamed it.
>>
>> <asp:textbox id="applicantID" CSSClass="textbox2Label"
>> TextMode="SingleLine" Columns="32" runat="server" />
>>
>> and
>>
>> .textbox2Label{
>> border-style:none;
>> background-color:#F6F6F6;
>> }
>>
>> I also tried this at runtime and it doesn't work there either.
>>
>> Tom.
>> >
>> > --
>> >
>> > Thanks,
>> > Carl Prothman
>> > Microsoft ASP.NET MVP
>> >
>> >
>>
>>
>
>



Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: MGRIDEOUT | last post by:
Hello, I have a class called clsPerson. A property of this class is Date_Of_Birth (DOB). In my Access Database the field is date/Time data Type. I am trying to set the class property DOB to...
28
by: kfrost | last post by:
I know this is probably simple but I have a C# form and the class for the form is called sbaSynch. I have a textbox name txtServerName. I'm creating a class to manipulate XML functions so I...
19
by: hamil | last post by:
I have a form with one button, Button1, and a Textbox, Textbox1 I have a class, class1 as follows. Public Class Class1 Public DeForm As Object Sub doit() DeForm.Textbox1.text = "It works"...
1
by: Anthony Nystrom | last post by:
I am trying to pass a text stream from streamwriter class to a richtextbox, or textbox doesn't matter which one. I have the file write version working fine such as: x.streamwriter =...
6
by: Lore Leunoeg | last post by:
Hello I derived a class MyControl from the Control class. Public Class MyControl Inherits Control Sub New() MyBase.New() End Sub End Class
16
by: Joel Byrd | last post by:
I am having this ridiculous problem of trying to set the innerHTML of a div node. It works in all other browsers, but internet explorer is giving me an "Unknown runtime error". This is actually...
16
by: Mike | last post by:
Hi, I have a form with some controls, and a different class that needs to modify some control properties at run time. Hoy can I reference the from so I have access to its controls and...
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
2
Hutt
by: Hutt | last post by:
Hello, I'm fairly new to vb.net and have a question I can't find an answer to. The site I'm working on is complex, but to keep things simple here's the basic problem. I have a site designed with a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.