Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 5th, 2003, 02:21 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default Setting the Style Sheet class

Hi...

I am doing a series of web pages where user interfaces are a central part; that is, input text fields, textareas, radio buttons etc. Due to the fact that I do not want to do it manually I have made a database representation of a UI, and then creating the UIs dynamically, however...

When using objects as HtmlInputText, HtmlTextArea etc. (the HTML server controls) I canont set the style (CSS) dynamically . The Web controls have got a property CssClass which would be great to have however this is not the case.

Is there a way, which is not a hack, to solve this? There must be others having this problem. Naturally you could do the hack, like...
Code:
new LiteralControl("<INPUT TYPE='text' CLASS='someClass'>")
however this is not nice! Didn't Microsoft thought of this!?

Thanks
Jacob.
__________________
Danish audio books for download at http://www.lytenbog.dk (Danske lydbøger til download).
 
Old August 13th, 2003, 02:22 AM
Authorized User
 
Join Date: Jun 2003
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to planeswalk
Default

Hi,

Actually there is a way for you to access and dynamically modify the styles (CSS) for HTML Controls. You use the Attributes collection for the HTML server control like so:

<script runat="server">
  ...
    myinput.Attributes("class") = "classname_1"
  ...
    myinput.Attributes("class") = "classname_2"
  ...
</script>
  ...
<input type="text" id="myinput" runat="server" />
  ...


Cheers!

Marlon Villarama
Support Team
Web Burner Hosting
marlon@webburner.com
www.webburner.com
877-535-2876
 
Old August 18th, 2003, 09:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks, just what i needed :D

I used the following in C#
Code:
control.Attributes["class"] = "inputControl";
Jacob.
 
Old August 18th, 2003, 09:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Will u change the class in runtime?!? if not write it in <asp:*** tag

Always:),
Hovik Melkomian.
 
Old August 20th, 2003, 01:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Default

[Don't bother reading this - I didn't see that you were using HTML Controls not Web Controls]

Cheers
Ken





Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the style sheet of the Master Page dotnetDeveloper BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 August 4th, 2008 09:56 AM
Chapter 2 -- Style Sheet problem. Doug Happ BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 4 January 10th, 2008 01:14 PM
cascading style sheet problem nikotromus ASP.NET 2.0 Professional 0 March 24th, 2006 07:49 PM
assigning a css style sheet from an element miguel XSLT 7 August 8th, 2004 01:21 PM
Relative Link to External Style Sheet arduk ASP.NET 1.0 and 1.1 Basics 1 June 18th, 2003 09:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.