Home > Forum > ASP.NET > css ediing dnamically in asp.net

css ediing dnamically in asp.net

by vijaymala dharmoji   on Feb 07, 2014   Category: ASP.NET  |  Views: 1503    |  Points: 5   |  Starter 
how to edit css template at runime

Bookmark and Share:
  User Reply  | Ask a question  |   Reply 
  Re :css ediing dnamically in asp.net   
by Thamil
on Mar 3 2014 4:50AM
Points : 10
Below sample code shows how to alter the css at runtime, I have placed the label inside div to apply style through div and added runat attribute. In page load, I have assigned the css name to div.

aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<link href="Style/Stylesheet1.css" rel="stylesheet" type="text/css" id="stylesheet" />
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<div id="divName" runat="server">
<asp:Label ID="Label1" runat="server" Text="Please enter the name"></asp:Label>

font-weight: bold;

Code behind part

protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
divName.Attributes["class"] = "testName";

hope this will help you.

Recent Post

Latest Posts

1 ??????? ?? ????? New! Forum