Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > CSS to webcontrols

Reply
Thread Tools

CSS to webcontrols

 
 
neilmcguigan@gmail.com
Guest
Posts: n/a
 
      10-07-2005
you can apply a style to an element type, class or id like this:

input
{
font-family:Tahoma;
}

this would apply the Tahoma font to all "<input..." elements

..MyClass
{
font-size:70%;
}

this would apply a font-size of 70% to all html elements with
class="MyClass" attribute

#MyId
{
margin:0px;
}

this would apply a margin of 0px to all elements with id="MyId"
attribute

you can also nest styles, like this:

#MyTable th
{
font-weight:bold;
}

this would apply a bold font to all "<th>" elements for the item with
id="MyTable"

HTH

Neil

 
Reply With Quote
 
 
 
 
Roger Moore
Guest
Posts: n/a
 
      10-07-2005
Hi all,

I have a beginner's question:

If webcontrols are rendered to suit different browsers using different HTML
syntax for each, how can I create a unified CSS stylesheet to them (using
the cssStyle attribute).

What I say is that I need to know which HTML tag i'm applying the style to,
in order to know which CSS styles are relevant to it.

Thanks in advance,
Roger.


 
Reply With Quote
 
 
 
 
Michel de Becdelièvre
Guest
Posts: n/a
 
      10-07-2005

"Roger Moore" <> a écrit dans le message de news:
...
> Hi all,
>
> I have a beginner's question:
>
> If webcontrols are rendered to suit different browsers using different
> HTML syntax for each, how can I create a unified CSS stylesheet to them
> (using the cssStyle attribute).
>
> What I say is that I need to know which HTML tag i'm applying the style
> to, in order to know which CSS styles are relevant to it.
>


Simple : you avoid System.Web.UI.WebControls.* (you only use real value
added cases such as repeater, datagrid, etc.), you use :
System.Web.UI.HtmlControls.* . This also gives you a good chance of
achieving Firefox compatibility (once you have updated your browsercaps).





 
Reply With Quote
 
Mr Newbie
Guest
Posts: n/a
 
      10-07-2005
Example.

<style type="text/css">
<!--
INPUT {
background-color: #99ccff;
color: black;
font-family: arial, verdana, ms sans serif;
font-weight: bold;
font-size: 12pt
}

TEXTAREA {
background-color: navy;
border: black 2px solid;
color: white;
font-family: arial, verdana, ms sans serif;
font-size: 12pt;
font-weight: normal
}

..altButtonFormat {
background-color: #c0c0c0;
font-family: verdana;
border: #000000 1px solid;
font-size: 12px;
color: #778899
}

..altTextField {
background-color: #ececec;
font-family: verdana;
font-size: 12pt;
color: #09c09c
}

..radioStyle {
background-color: #FF0000;
border: #000000 solid 1px;
font-family: verdana;
font-size: 12px;
color: #000000
}
-->



"Roger Moore" <> wrote in message
news:...
> Thanks for answering, but I'm afraid you didn't understand my question:
> ASP.NET renders webcontrols as different HTML tags for different HTML
> versions, browsers etc. so when I apply a cssStyle to an ASP.NET
> webcontrol I don't know if I'm actually applying it to INPUT, TEXTAREA or
> whatever HTML tag ASP.NET chooses to use for my <asp:textbox/> (I take
> this tag only as an example - other tags may use a broad variety of other
> interchanging HTML tags) control.
>
> I hope I made myself clear this time.. thanks again..
>
> <> wrote in message
> news: oups.com...
>> you can apply a style to an element type, class or id like this:
>>
>> input
>> {
>> font-family:Tahoma;
>> }
>>
>> this would apply the Tahoma font to all "<input..." elements
>>
>> .MyClass
>> {
>> font-size:70%;
>> }
>>
>> this would apply a font-size of 70% to all html elements with
>> class="MyClass" attribute
>>
>> #MyId
>> {
>> margin:0px;
>> }
>>
>> this would apply a margin of 0px to all elements with id="MyId"
>> attribute
>>
>> you can also nest styles, like this:
>>
>> #MyTable th
>> {
>> font-weight:bold;
>> }
>>
>> this would apply a bold font to all "<th>" elements for the item with
>> id="MyTable"
>>
>> HTH
>>
>> Neil
>>

>
>



 
Reply With Quote
 
Roger Moore
Guest
Posts: n/a
 
      10-07-2005
Thanks for answering, but I'm afraid you didn't understand my question:
ASP.NET renders webcontrols as different HTML tags for different HTML
versions, browsers etc. so when I apply a cssStyle to an ASP.NET webcontrol
I don't know if I'm actually applying it to INPUT, TEXTAREA or whatever HTML
tag ASP.NET chooses to use for my <asp:textbox/> (I take this tag only as an
example - other tags may use a broad variety of other interchanging HTML
tags) control.

I hope I made myself clear this time.. thanks again..

<> wrote in message
news: oups.com...
> you can apply a style to an element type, class or id like this:
>
> input
> {
> font-family:Tahoma;
> }
>
> this would apply the Tahoma font to all "<input..." elements
>
> .MyClass
> {
> font-size:70%;
> }
>
> this would apply a font-size of 70% to all html elements with
> class="MyClass" attribute
>
> #MyId
> {
> margin:0px;
> }
>
> this would apply a margin of 0px to all elements with id="MyId"
> attribute
>
> you can also nest styles, like this:
>
> #MyTable th
> {
> font-weight:bold;
> }
>
> this would apply a bold font to all "<th>" elements for the item with
> id="MyTable"
>
> HTH
>
> Neil
>



 
Reply With Quote
 
Roger Moore
Guest
Posts: n/a
 
      10-07-2005
Thanks Michael,

I understand you recommend using repeater - that's was my default, but I
really do want to use some of the more complex .NET webcontrols.
You've mentioned datagrid: how do I know which set of HTML tags are involved
when .NET renders this tag (on all browsers that is)?.. it's easy to assume
it only uses table tags (TD, TR, TBODY etc) - but how can I make sure that,
for exampe, it won't stick a SPAN to one of the TDs?

Thanks,
Roger.


"Michel de Becdelièvre" <> wrote in message
news:ud$...
>
> "Roger Moore" <> a écrit dans le message de news:
> ...
>> Hi all,
>>
>> I have a beginner's question:
>>
>> If webcontrols are rendered to suit different browsers using different
>> HTML syntax for each, how can I create a unified CSS stylesheet to them
>> (using the cssStyle attribute).
>>
>> What I say is that I need to know which HTML tag i'm applying the style
>> to, in order to know which CSS styles are relevant to it.
>>

>
> Simple : you avoid System.Web.UI.WebControls.* (you only use real value
> added cases such as repeater, datagrid, etc.), you use :
> System.Web.UI.HtmlControls.* . This also gives you a good chance of
> achieving Firefox compatibility (once you have updated your browsercaps).
>
>
>
>
>



 
Reply With Quote
 
Scott Allen
Guest
Posts: n/a
 
      10-08-2005
On Fri, 7 Oct 2005 22:01:18 +0200, "Roger Moore"
<> wrote:
>
>If webcontrols are rendered to suit different browsers using different HTML
>syntax for each, how can I create a unified CSS stylesheet to them (using
>the cssStyle attribute).
>


This is a tough question to answer. On one hand it's nice to work with
server controls because they present a higher level of abstraction.
Someday we will think of HTML as a primitive assembly language for the
web.

In 2.0 we have skin files, which are a server-side type of stylesheet,
but as I'm sure someone will point out, not a standard. Nevertheless,
they make it easy to manage and style the complex server side controls
like DataViews and Calendars.

I've written a bit about Themes and Skins here:

http://www.odetocode.com/Articles/423.aspx
http://odetocode.com/Blogs/scott/arc...9/01/2144.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/
 
Reply With Quote
 
Roger Moore
Guest
Posts: n/a
 
      10-08-2005
Thanks,

But since I'm using 1.1, it's back to "good old HTML" for me when creating
user controls..
Fortunately enough, I am not really required for one of the datagrid (etc.)
fancy functionalities in my app.

"Scott Allen" <> wrote in message
news:...
> On Fri, 7 Oct 2005 22:01:18 +0200, "Roger Moore"
> <> wrote:
>>
>>If webcontrols are rendered to suit different browsers using different
>>HTML
>>syntax for each, how can I create a unified CSS stylesheet to them (using
>>the cssStyle attribute).
>>

>
> This is a tough question to answer. On one hand it's nice to work with
> server controls because they present a higher level of abstraction.
> Someday we will think of HTML as a primitive assembly language for the
> web.
>
> In 2.0 we have skin files, which are a server-side type of stylesheet,
> but as I'm sure someone will point out, not a standard. Nevertheless,
> they make it easy to manage and style the complex server side controls
> like DataViews and Calendars.
>
> I've written a bit about Themes and Skins here:
>
> http://www.odetocode.com/Articles/423.aspx
> http://odetocode.com/Blogs/scott/arc...9/01/2144.aspx
>
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object reference not set to an instance of an object. System.Web.UI.WebControls.ListItemCollection.SaveViewState() System.Web.UI.WebControls.ListControl.SaveViewState() Brano ASP .Net 3 11-08-2005 12:29 PM
CSS and WebControls Roger Moore ASP .Net Web Controls 1 10-07-2005 11:04 PM
CSS Layout question - how to duplicate a table layout with CSS Eric ASP .Net 4 12-24-2004 04:54 PM
Is there a way to set the a CSS property to be explicitly the same as another CSS property? Joshua Beall HTML 1 12-10-2003 07:21 PM
print.css and screen.css tom watson HTML 1 09-09-2003 02:48 PM



Advertisments