Style Properties

Almost all parts of ASP.NET scripts are information processors. They take data values input by users or extracted from files and databases and convert that data to information through processing routines. At the same time, scripts can arrange and style to information through processing routines. At the same time, scripts can arrange and style the output for differing routines. At the same time, scripts can arrange and style the output for differing visual effects. They can create XHML code for delivery to the browser, and they would style the information for dramatic effect.

Altering the style feature of HTML elements on the fly is recognizable to those who have effort with Dynamic HTML. DHTML is a browser occurrence which uses Cascading Style Sheets (CSS) and the JavaScript Language to influence the properties and means of XHTML tags to act as on the user response to user or browser events. In ASP.NET, this type of styling can obtain place, in this case by controlling settings and server scripts quite than CSS and browser scripts.

Dynamic HTML

Browser-based DHTML means are described through the following button that changes its visual characteristics when clicked. In this case, CSS property settings are applied to the button under local script control.
<script type=”text/javascript”>
function ChangeFormat()
document.getElementById(“Button”).style.backgroundColor = “#FF0033”
document.getElementById(“Button”).style.color = “#FFF000”
document.getElementById(“Button”).style.fontFamily = “comic sans ms”
document.getElementById(“Button”).value = “Thank You”

<input id=”Button” type=”button” value=”Click Me” onclick=”ChangeFormat ()”
style=”background-color:#F0F0F1; color:#990000″/>

The button is styled originally with an in-line CSS style sheet setting the background and text colors. This button also is given an id (Button) for situation in the associated browser script build in the JavaScript language. The ChangeFormat () function is known as on a mouse click to dynamically set a variety of CSS styles for the button to change its appearance. The entire scripting is local to the browser.

Dynamic Server CSS Styling

The similar style changes can be made to happen with a server script. The necessity is which the button requires to be a server control to create it accessible by the script.

<SCRIPT Runat=”Server”>

Sub Change_Format (Src As Object, Args As EventArgs)

Button.Style(“background-color”) = “#FF0033”
Button.Style(“color”) = “#FFFF00”
Button.Style(“font-family”) = “comic sans ms”
Button.Text = “Thanking You”

End Sub


<form Runat=”Server”>

<asp:Button id=”MyButton” Text=”Click Me” Runat=”Server”
Style=”background-color:#F0F0F0; color:#990000″ OnClick=”Change_Format”/>


Sandeep Shankar
Sandeep Shankar
Sandeep Shankar is a content writer with Webdhoom, a digital marketing firm, which assists both startups and established businesses to improve online traffic, reach out to target audience, increase sales and build loyal customers through best SEO and SMO services. His articles and blogs are widely read and shared on different online platforms.