Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > programmatically modify Panel's CSS properties

Reply
Thread Tools

programmatically modify Panel's CSS properties

 
 
John A Grandy
Guest
Posts: n/a
 
      09-20-2004
in a code-behind event for a Page , is it possible to obtain a reference to
a Panel's CSS attribute, and then modify the CSS instance's properties ?


 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      09-21-2004
Hi John,

The CssClass is just a string that points to the stylesheet class.
Therefore, you can just switch to using a different class at any time. Code
below.

Is that what you meant?

Ken
Microsoft MVP [ASP.NET]



<%@ Page Language="vb" AutoEventWireup="false" Codebehind="pnlev.aspx.vb"
Inherits="p4320work.pnlev"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>pnlev</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<style>
.expandable { FONT-WEIGHT: bold; CURSOR: hand; COLOR: navy;
BACKGROUND-COLOR: green; TEXT-DECORATION: underline }
.otherclass { FONT-WEIGHT: bold; CURSOR: hand; COLOR: yellow;
BACKGROUND-COLOR: blue; TEXT-DECORATION: underline }

</style>
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<aspanel id="Panel1" runat="server" Width="352px" Height="112px"
CssClass="expandable">Panel</aspanel>
<P>
</P>
<P>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>
</form>
</body>
</HTML>

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Panel1.CssClass = "otherclass"
End Sub

"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:...
> in a code-behind event for a Page , is it possible to obtain a reference
> to
> a Panel's CSS attribute, and then modify the CSS instance's properties ?
>
>


 
Reply With Quote
 
 
 
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      09-21-2004
hi John, you can provide the style to your webcontrol by passing a style
sheet through the cssClass property like showcased by ken Cox or you can
set/retrieve style through the CssStyleCollection exposed by the control
like below :

Panel1.Style("background-color") = "blue"
Dim myPanelBackground As String = Panel1.Style("BACKGROUND-COLOR")
Response.Write(myPanelBackground)

This will get included as inline css ofcourse ;p

Regards,
Alessandro Zifiglio
http://www.dotnetbox.com (The custom web control that lets you drag and
resize content on your pages like as if you were in Visual Studio.NET
designer.)

"Ken Cox [Microsoft MVP]" <> wrote in message
news:%...
> Hi John,
>
> The CssClass is just a string that points to the stylesheet class.
> Therefore, you can just switch to using a different class at any time.

Code
> below.
>
> Is that what you meant?
>
> Ken
> Microsoft MVP [ASP.NET]
>
>
>
> <%@ Page Language="vb" AutoEventWireup="false" Codebehind="pnlev.aspx.vb"
> Inherits="p4320work.pnlev"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <title>pnlev</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> <meta name="vs_defaultClientScript" content="JavaScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
> <style>
> .expandable { FONT-WEIGHT: bold; CURSOR: hand; COLOR: navy;
> BACKGROUND-COLOR: green; TEXT-DECORATION: underline }
> .otherclass { FONT-WEIGHT: bold; CURSOR: hand; COLOR: yellow;
> BACKGROUND-COLOR: blue; TEXT-DECORATION: underline }
>
> </style>
> </HEAD>
> <body MS_POSITIONING="FlowLayout">
> <form id="Form1" method="post" runat="server">
> <aspanel id="Panel1" runat="server" Width="352px" Height="112px"
> CssClass="expandable">Panel</aspanel>
> <P>
> </P>
> <P>
> <asp:Button id="Button1" runat="server"

Text="Button"></asp:Button></P>
> </form>
> </body>
> </HTML>
>
> Private Sub Button1_Click _
> (ByVal sender As System.Object, _
> ByVal e As System.EventArgs) _
> Handles Button1.Click
> Panel1.CssClass = "otherclass"
> End Sub
>
> "John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
> news:...
> > in a code-behind event for a Page , is it possible to obtain a reference
> > to
> > a Panel's CSS attribute, and then modify the CSS instance's properties ?
> >
> >

>



 
Reply With Quote
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      09-21-2004
Also if you are still using the .net 1.0 version to the framework, then if
i'm not mistaken the style property is uppercase. Currently i'm working with
1.1 and this does not seem to be a problem since in my code sample i have
both uppercase and lowercase
background-color
&
BACKGROUND-COLOR

Regards,
Alessandro Zifiglio
http://www.dotnetbox.com (The custom web control that lets you drag and
resize content on your pages like as if you were in Visual Studio.NET
designer.)

"Alessandro Zifiglio" <> wrote in
message news:%...
> hi John, you can provide the style to your webcontrol by passing a style
> sheet through the cssClass property like showcased by ken Cox or you can
> set/retrieve style through the CssStyleCollection exposed by the control
> like below :
>
> Panel1.Style("background-color") = "blue"
> Dim myPanelBackground As String = Panel1.Style("BACKGROUND-COLOR")
> Response.Write(myPanelBackground)
>
> This will get included as inline css ofcourse ;p
>
> Regards,
> Alessandro Zifiglio
> http://www.dotnetbox.com (The custom web control that lets you drag and
> resize content on your pages like as if you were in Visual Studio.NET
> designer.)
>
> "Ken Cox [Microsoft MVP]" <> wrote in message
> news:%...
> > Hi John,
> >
> > The CssClass is just a string that points to the stylesheet class.
> > Therefore, you can just switch to using a different class at any time.

> Code
> > below.
> >
> > Is that what you meant?
> >
> > Ken
> > Microsoft MVP [ASP.NET]
> >
> >
> >
> > <%@ Page Language="vb" AutoEventWireup="false"

Codebehind="pnlev.aspx.vb"
> > Inherits="p4320work.pnlev"%>
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> > <HTML>
> > <HEAD>
> > <title>pnlev</title>
> > <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
> > <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> > <meta name="vs_defaultClientScript" content="JavaScript">
> > <meta name="vs_targetSchema"
> > content="http://schemas.microsoft.com/intellisense/ie5">
> > <style>
> > .expandable { FONT-WEIGHT: bold; CURSOR: hand; COLOR: navy;
> > BACKGROUND-COLOR: green; TEXT-DECORATION: underline }
> > .otherclass { FONT-WEIGHT: bold; CURSOR: hand; COLOR: yellow;
> > BACKGROUND-COLOR: blue; TEXT-DECORATION: underline }
> >
> > </style>
> > </HEAD>
> > <body MS_POSITIONING="FlowLayout">
> > <form id="Form1" method="post" runat="server">
> > <aspanel id="Panel1" runat="server" Width="352px" Height="112px"
> > CssClass="expandable">Panel</aspanel>
> > <P>
> > </P>
> > <P>
> > <asp:Button id="Button1" runat="server"

> Text="Button"></asp:Button></P>
> > </form>
> > </body>
> > </HTML>
> >
> > Private Sub Button1_Click _
> > (ByVal sender As System.Object, _
> > ByVal e As System.EventArgs) _
> > Handles Button1.Click
> > Panel1.CssClass = "otherclass"
> > End Sub
> >
> > "John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
> > news:...
> > > in a code-behind event for a Page , is it possible to obtain a

reference
> > > to
> > > a Panel's CSS attribute, and then modify the CSS instance's properties

?
> > >
> > >

> >

>
>



 
Reply With Quote
 
Guest
Guest
Posts: n/a
 
      12-22-2004


> in a code-behind event for a Page , is it possible to obtain a reference to
> a Panel's CSS attribute, and then modify the CSS instance's properties ?
>
>


So if the CSSStyleCollection only gets inlines CSS values, how does one read the linked CSS from an external file? R L y d a (t a) G G M I T G (t o d) c o

User submitted from AEWNET (http://www.aewnet.com/)
 
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
Modify Web.Config Programmatically? Stewart Armbrecht ASP .Net 2 02-17-2010 08:05 PM
Programmatically Modify Site-Map Nodes in Memory =?Utf-8?B?YmJ1cmtoYXJ0?= ASP .Net 1 03-17-2006 08:51 PM
programmatically modify Panel's CSS properties John A Grandy ASP .Net Web Controls 0 09-20-2004 07:03 PM
Modify the SessionState mode programmatically Promenade ASP .Net 0 12-15-2003 08:31 PM
Sending MSOutlook mtg notifications programmatically(delete,modify) Kevin ASP .Net 0 11-11-2003 08:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57