Skip to content

Setting Up CSS on any DIV using C#

Dilip Solanki

Dilip Solanki

Asked Jan 12, 2013, 10:29 PM EST1 answer
Share
LinkedInX
Good Afternoon Friends..
I want to apply stylesheet dynamically on
, which i have created in design time.
I have only 1 .aspx webpage, which i have created in visual studio 2010.
My default.aspx page code as below:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
 
 
 
  
 
 
 
  
 
 
Now i want to apply stylesheet on above div with  "testing" id.

I want to apply these stylesheet properties with div:
background-color
border
width
height
font

I have did this task by using javascript but now i want to do this using c#.
How can i do it, plz help me...?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Akkiraju Ivaturi
    0
    Create a CSS class for the set of stylesheet properties and refer the stylesheet file in your UI.

    Then in the code behind:

    YourDIVID.Attributes["class"]="your css class name";

    This adds the class attribute to the DIV tag.
    0