ASP.NET immediately tutorial 5

xiaoxiao2021-03-06  20

Application style to HTML server control

The Web is a flexible user interface environment, and different sites are vision and feelings. Laminated style

The widespread application of Table (CSS), greatly enriched the design of the Web. All ASP.NET HTML Server Controls and WEB Service

The instructor control has been designed to provide first-class CSS style support. This section discusses how to apply style to service

The device control, and the demo server control is controlled in the fine appearance provided in Web Forms.

Application style to HTML server control

Standard HTML tags support CSS via style attribute, Style property is divided by a series of semicolon-segregated

Attribute / value is defined. For example {font: 12pt Verdana; font-weight: 700; color: orange;}. About I

E Browser For more information on CSS properties, please refer to MSDN Web Workshop CSS Attributes Refer

ENCE page. All ASP.NET's HTML server control can accept CSS style like a standard HTML flag.

. The following example illustrates the application of some styles to different HTML server controls. If you look back to the client

The source program, you will find that these are sent to the client in the style referenced in the control.

C # style1.aspx

[Run] | [Source]

The CSS also defines the Class property, and the CSS style is set in the document. This belongs

The advantage of sex is that only one need to define it, it can be applied to different tabs without the need to redefine the label itself.

style. The style of the HTML server control can also be managed in this way. Please see the example below:

C # style2.aspx

[Run] | [Source]

When the ASP.NET page is parsed, style information is assembled to system.Web.ui.htmlControls.html

The style attribute on the Control class (type is CSSStyleCollection). This attribute creates a dictionary to word

The value in the collection of string indexes, populates each style attribute value of the application control style. For example, you can use the following

The code settings and retrieve the Width style property of the HTMLInputText server control.

The following example shows you how to use the Style collection property, manipulate the HTML server control through the program.

formula

C # style3.aspx

[Run] | [Source]

Application style to web server control

Web Server Controls provide additional support levels for style, which adds several strong types for common style settings.

Attributes. Commonly used patterns include background colors, foreground, font names, and size, width, font weight, and more. These samples

The type of property is a subset of the style behavior that can be used in HTML, and as a platform attribute, in System.Web.u

The I.WebControls.WebControl base class is expanded directly. The benefits of using these properties are in development tools, examples

For example, in VS.NET, they provide compile time type checks and status completion.

The following example shows a calendar control applied to a number of styles (as a control, and containing a useless

Style calendar control). Note When you set a class type property, such as font, you need to use subastribute syntax

Attribute Name - Submount Name.

C # style4.aspx

[Run] | [Source]

Name Space System.Web.ui.WebControls Contains a Style base class, which can package common style properties (other

Style classes, such as TableStyle, and TableItemStyle, are inherited from this base class).

Many server controls extends this type of property that specifies the style of the control branch element. For example, the calendar control extends many style properties: DayStyle, WeekenddayStyle, TodayDayStyle, SelectedDaysty

Le, OtherMonthdayStyle, and NextPrevStyle, and more. You can use the subastribute syntax name - child

The property name is set to set the branch attributes of these styles, as described below:

C # style5.aspx

[Run] | [Source]

A subtle difference syntax, allowing each Style property, nested as a child element in the web server control label

in.

Backcolor = "olivedrab" height = "50px" />

The following example shows alternating syntax, but functions as the previous one.

C # style6.aspx

[Run] | [Source]

As with the HTML server control, you can use the CSS class definition to apply the style to the web server control. WEBC

The Ontrol base class extends a string property, called CssClass, used to set the style class:

C # style7.aspx

[Run] | [Source]

If the property set to the server control does not meet any strong type of property of the control, then this attribute and value will be

Put it in the Attributes collection of the control. By default, the server control will not be modified by reference.

Sexually return to a request for browser client. This means that the properties of the styles and classes can be applied directly to the server.

Controls without using the strong type properties of these controls. Of course, understand this concept needs to understand the actual reference of the control.

He is also a flexible way of applying style. This method is especially useful for standard form input controls.

Please see the example below:

C # style8.aspx

[Run] | [Source]

By using the ApplyStyle method of the WebControl base class, the style of the web server control can also be set by the program,

Like the following code:

Login: /

PASSWORD:

View: ...

The following example demonstrates the above code

C # style9.aspx

[Run] | [Source]

This chapter section:

1. ASP.NET HTML Server Control and Web Server Control Family provide first-class CSS style support.

2. You can apply the style by setting the style or class properties of the control. These settings can pass through the control of Attribute

The S collection is accessed. For HTML server controls, the branch value of the style properties can pass through the control's style collection

Come.

3. Most commonly used style settings have been a strong type attribute that the web server control itself

4. System.Web.ui.WebControls Namespace contains the Style base class, encapsulates common type properties. a lot of

The Web server control extends this property as a branch reference element.

5. For server controls, using the ApplyStyle method of the webcontrol base class can set the style.

Chinese Professional Network WinCheer Translation from ASP.NET. . . . to be continued. . . . . . . . .

转载请注明原文地址:https://www.9cbs.com/read-40237.html

New Post(0)