asp.net

How to apply CSS style in the Label control from code-behind in ASP.NET in C#

You can apply CSS style from code behind by accessing the properties of the control with the help of its Id. Most of the CSS styles can be applied using the Font property and its sub properties of the Label control. However you can use ForeColor and BackColor directly from the Label control.

TestApplyCSS.aspx

<%@ Page Language=”C#” AutoEventWireup=”false” …

Learn more

How to change the text of the Label control from the code-behind in VB.NET

TestPage (.aspx)

<%@ Page Language=”vb” AutoEventWireup=”false” CodeBehind=”TestPage.aspx.vb” Inherits=”TestChange.TestPage” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”https://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>Change the text of the Label control from the code-behind</title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

<asp:Label ID=”LabelTest” runat=”server” Text=”My test label”></asp:Label>

</div>

</form>

</body>

</html>

Test page code-behind (.vb)

‘TestPage.apsx.vb

Public Class TestPage

Inherits System.Web.UI.Page

Protected Sub …

Learn more

How to change the text of the Label control from the code-behind in C#

TestPage (.aspx)

<%@ Page Language=”C#” AutoEventWireup=”false” CodeBehind=”TestPage.aspx.cs” Inherits=”TestChange.TestPage” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”https://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>Change the text of the Label control from the code-behind</title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

<asp:Label ID=”LabelTest” runat=”server” Text=”My test label”></asp:Label>

</div>

</form>

</body>

</html>

Test page code-behind (.cs)

//

// TestPage.aspx.cs

//

protected void Page_Load(object sender, EventArgs e)

{

// changing text from …

Learn more

How to use different colored highlights in a select menu with CSS

You can assign classes to menu options, to create multiple background colors within the drop-down color. In this case you need to set only the color and background-color properties for a menu item. The next two test files show this:

 

File test.css

.blue {

background-color: #ADD8E6;

color: #000000;

}

.red {

background-color: #E20A0A;

color: #ffffff;

}

.green {

background-color: …

Learn more

How to display table rows in alternating colors with CSS

Displaying table rows in alternating colors is a common way to help users identify which row they’re focused on. You can use CSS classes to create this effect. You can add to the CSS rules shown in the article How to display spreadsheet data in an attractive and usable way with CSS one additional rule, which …

Learn more

How to add a borders to a table with CSS

The HTML border attribute doesn’t create the prettiest of borders for tables. You can use a CSS border, which gives you more flexibility in terms of design.

You can use the next CSS code to specify the border around the table:

.datatable

{

border: 4px solid #04B404;

border-collapse: collapse;

}

You can render the border around table cells with …

Learn more

How to use HTML table specification tags and attributes

The (X)HTML table specification includes tags and attributes which you can use to ensure that the content of the table is clear when it’s read out to users who can’t see the layout. In the next test.html file these tags are marked with bold.

File test.html

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”

“https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

<html xmlns=”https://www.w3.org/1999/xhtml” lang=”en-US”>

<head>

<title>How to use HTML …

Learn more