Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Style Property of Controls


Message #1 by "Paul Litwin" <plitwin@m...> on Sat, 24 Mar 2001 07:56:44 -0800
Any reason why the Style property of Web Form controls (HTML and ASP.NET) is

read-only? Sure would be nice if this was read/write.



Paul

=====================================

Paul Litwin

Litwin Consulting, MCW Technologies

ASP Connections Conference Chair

mailto:plitwin@m...

http://www.asp-connections.com

=====================================





Message #2 by "Richard Anderson" <rja@a...> on Sun, 25 Mar 2001 17:13:11 +0100
What are you trying to achieve ? If you want to apply common styles to

controls you can call methods like Style.CopyFrom (copy everything from the

source style) or Style.MergeWith (just copy missing attributes)



You can override CreateControlStyle to return your own style implementation

for custom controls.



HTH,



Richard.



----- Original Message -----

From: "Paul Litwin" <plitwin@m...>

To: "ASP+" <aspx@p...>

Sent: Saturday, March 24, 2001 4:56 PM

Subject: [aspx] Style Property of Controls





> Any reason why the Style property of Web Form controls (HTML and ASP.NET)

is

> read-only? Sure would be nice if this was read/write.

>

> Paul

> =====================================

> Paul Litwin

> Litwin Consulting, MCW Technologies

> ASP Connections Conference Chair

> mailto:plitwin@m...

> http://www.asp-connections.com

> =====================================

>

>

>

> ---

> SoftArtisans helps developers build robust, scalable Web applications!

> Excel Web reports, charts: http://www.softartisans.com/excelwriter.html

> File uploads: http://www.softartisans.com/saf.html

> Transactional file management: http://www.softartisans.com/saf1.html

> Scalability: http://www.softartisans.com/saxsession.html

> ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html




>



Message #3 by "Mike Amundsen" <mike@a...> on Sun, 25 Mar 2001 14:19:23 -0500
RA:



i was thinking that I could do the following:



<asp:label id="mylabel" style="color:red;" runat="server" />



then, on a click event simply do this:



mylabel.style="color:blue'";



however i get an error.



MCA



-----Original Message-----

From: Richard Anderson [mailto:rja@a...]

Sent: Sunday, March 25, 2001 11:13 AM

To: ASP+

Subject: [aspx] Re: Style Property of Controls





What are you trying to achieve ? If you want to apply common styles to

controls you can call methods like Style.CopyFrom (copy everything from the

source style) or Style.MergeWith (just copy missing attributes)



You can override CreateControlStyle to return your own style implementation

for custom controls.



HTH,



Richard.



Message #4 by rja@a... on Mon, 26 Mar 2001 17:29:09 +0100
Something like this should work:



mylabel.style.Add("color","blue");



Cheers,



Rich



PS. Anybody know if this list is moderated  ? It's seem __very__ slow at

posting emails etc.



[Moderator's note: yes, it is moderated :) ]



----- Original Message -----

From: "Mike Amundsen" <mike@a...>

To: "ASP+" <aspx@p...>

Sent: Sunday, March 25, 2001 8:19 PM

Subject: [aspx] Re: Style Property of Controls





> RA:

>

> i was thinking that I could do the following:

>

> <asp:label id="mylabel" style="color:red;" runat="server" />

>

> then, on a click event simply do this:

>

> mylabel.style="color:blue'";

>

> however i get an error.

>

> MCA

>

> -----Original Message-----

> From: Richard Anderson [mailto:rja@a...]

> Sent: Sunday, March 25, 2001 11:13 AM

> To: ASP+

> Subject: [aspx] Re: Style Property of Controls

>

>

> What are you trying to achieve ? If you want to apply common styles to

> controls you can call methods like Style.CopyFrom (copy everything from

the

> source style) or Style.MergeWith (just copy missing attributes)

>

> You can override CreateControlStyle to return your own style

implementation

> for custom controls.

>

> HTH,

>

> Richard.



Message #5 by rja@a... on Mon, 26 Mar 2001 17:52:21 +0100
Should have said you can also write:



mylabel.style["color"] = "blue";



to remove a style you can write either:



mylabel.style["color"] = null;



or 



mylabel.style.Remove("color")



Cheers



Rich



----- Original Message ----- 

From: <rja@a...>

To: "ASP+" <aspx@p...>

Sent: Monday, March 26, 2001 5:29 PM

Subject: [aspx] Re: Style Property of Controls





> Something like this should work:

> 

> mylabel.style.Add("color","blue");

> 

> Cheers,

> 

> Rich

> 

> PS. Anybody know if this list is moderated  ? It's seem __very__ slow at

> posting emails etc.

> 

> [Moderator's note: yes, it is moderated :) ]

> 

> ----- Original Message -----

> From: "Mike Amundsen" <mike@a...>

> To: "ASP+" <aspx@p...>

> Sent: Sunday, March 25, 2001 8:19 PM

> Subject: [aspx] Re: Style Property of Controls

> 

> 

> > RA:

> >

> > i was thinking that I could do the following:

> >

> > <asp:label id="mylabel" style="color:red;" runat="server" />

> >

> > then, on a click event simply do this:

> >

> > mylabel.style="color:blue'";

> >

> > however i get an error.

> >

> > MCA

> >

> > -----Original Message-----

> > From: Richard Anderson [mailto:rja@a...]

> > Sent: Sunday, March 25, 2001 11:13 AM

> > To: ASP+

> > Subject: [aspx] Re: Style Property of Controls

> >

> >

> > What are you trying to achieve ? If you want to apply common styles to

> > controls you can call methods like Style.CopyFrom (copy everything from

> the

> > source style) or Style.MergeWith (just copy missing attributes)

> >

> > You can override CreateControlStyle to return your own style

> implementation

> > for custom controls.

> >

> > HTH,

> >

> > Richard.

> 

> 

Message #6 by "Mike Amundsen" <mike@a...> on Mon, 26 Mar 2001 17:30:42 -0500
oh, i see!



it's an object! <DOH>



MCA





-----Original Message-----

From: rja@a... [mailto:rja@a...]

Sent: Monday, March 26, 2001 11:52 AM

To: ASP+

Subject: [aspx] Re: Style Property of Controls





Should have said you can also write:



mylabel.style["color"] = "blue";



to remove a style you can write either:



mylabel.style["color"] = null;



or 



mylabel.style.Remove("color")



Cheers



Rich



----- Original Message ----- 

From: <rja@a...>

To: "ASP+" <aspx@p...>

Sent: Monday, March 26, 2001 5:29 PM

Subject: [aspx] Re: Style Property of Controls





> Something like this should work:

> 

> mylabel.style.Add("color","blue");

> 

> Cheers,

> 

> Rich

> 

> PS. Anybody know if this list is moderated  ? It's seem __very__ slow at

> posting emails etc.

> 

> [Moderator's note: yes, it is moderated :) ]

> 

> ----- Original Message -----

> From: "Mike Amundsen" <mike@a...>

> To: "ASP+" <aspx@p...>

> Sent: Sunday, March 25, 2001 8:19 PM

> Subject: [aspx] Re: Style Property of Controls

> 

> 

> > RA:

> >

> > i was thinking that I could do the following:

> >

> > <asp:label id="mylabel" style="color:red;" runat="server" />

> >

> > then, on a click event simply do this:

> >

> > mylabel.style="color:blue'";

> >

> > however i get an error.

> >

> > MCA

> >

> > -----Original Message-----

> > From: Richard Anderson [mailto:rja@a...]

> > Sent: Sunday, March 25, 2001 11:13 AM

> > To: ASP+

> > Subject: [aspx] Re: Style Property of Controls

> >

> >

> > What are you trying to achieve ? If you want to apply common styles to

> > controls you can call methods like Style.CopyFrom (copy everything from

> the

> > source style) or Style.MergeWith (just copy missing attributes)

> >

> > You can override CreateControlStyle to return your own style

> implementation

> > for custom controls.

> >

> > HTH,

> >

> > Richard.



Message #7 by "Paul Litwin" <plitwin@m...> on Mon, 26 Mar 2001 14:41:38 -0800
Thanks, everyone. So the property is read-only but there are methods you can

use to write the individual styles. That's fine--don't know why I didn't see

that. Thanks.



Paul



=====================================

Paul Litwin

Litwin Consulting, MCW Technologies, and

DevConnections Conferences

mailto:plitwin@m...

http://www.devconnections.com

http://www.developershandbook.com

=====================================







-----Original Message-----

From: rja@a... [mailto:rja@a...]

Sent: Monday, March 26, 2001 8:52 AM

To: ASP+

Subject: [aspx] Re: Style Property of Controls





Should have said you can also write:



mylabel.style["color"] = "blue";



to remove a style you can write either:



mylabel.style["color"] = null;



or



mylabel.style.Remove("color")



Cheers



Rich



----- Original Message -----

From: <rja@a...>

To: "ASP+" <aspx@p...>

Sent: Monday, March 26, 2001 5:29 PM

Subject: [aspx] Re: Style Property of Controls





> Something like this should work:

>

> mylabel.style.Add("color","blue");

>

> Cheers,

>

> Rich

>

> PS. Anybody know if this list is moderated  ? It's seem __very__ slow at

> posting emails etc.

>

> [Moderator's note: yes, it is moderated :) ]

>

> ----- Original Message -----

> From: "Mike Amundsen" <mike@a...>

> To: "ASP+" <aspx@p...>

> Sent: Sunday, March 25, 2001 8:19 PM

> Subject: [aspx] Re: Style Property of Controls

>

>

> > RA:

> >

> > i was thinking that I could do the following:

> >

> > <asp:label id="mylabel" style="color:red;" runat="server" />

> >

> > then, on a click event simply do this:

> >

> > mylabel.style="color:blue'";

> >

> > however i get an error.

> >

> > MCA

> >

> > -----Original Message-----

> > From: Richard Anderson [mailto:rja@a...]

> > Sent: Sunday, March 25, 2001 11:13 AM

> > To: ASP+

> > Subject: [aspx] Re: Style Property of Controls

> >

> >

> > What are you trying to achieve ? If you want to apply common styles to

> > controls you can call methods like Style.CopyFrom (copy everything from

> the

> > source style) or Style.MergeWith (just copy missing attributes)

> >

> > You can override CreateControlStyle to return your own style

> implementation

> > for custom controls.

> >

> > HTH,

> >

> > Richard.




  Return to Index