Trang chủ
Bài viết mới
Diễn đàn
Bài mới trên hồ sơ
Hoạt động mới nhất
VIDEO
Mùa Tết
Văn Học Trẻ
Văn Học News
Media
New media
New comments
Search media
Đại Học
Đại cương
Chuyên ngành
Triết học
Kinh tế
KHXH & NV
Công nghệ thông tin
Khoa học kĩ thuật
Luận văn, tiểu luận
Phổ Thông
Lớp 12
Ngữ văn 12
Lớp 11
Ngữ văn 11
Lớp 10
Ngữ văn 10
LỚP 9
Ngữ văn 9
Lớp 8
Ngữ văn 8
Lớp 7
Ngữ văn 7
Lớp 6
Ngữ văn 6
Tiểu học
Thành viên
Thành viên trực tuyến
Bài mới trên hồ sơ
Tìm trong hồ sơ cá nhân
Credits
Transactions
Xu: 0
Đăng nhập
Đăng ký
Có gì mới?
Tìm kiếm
Tìm kiếm
Chỉ tìm trong tiêu đề
Bởi:
Hoạt động mới nhất
Đăng ký
Menu
Đăng nhập
Đăng ký
Install the app
Cài đặt
Chào mừng Bạn tham gia Diễn Đàn VNKienThuc.com -
Định hướng Forum
Kiến Thức
- HÃY TẠO CHỦ ĐỀ KIẾN THỨC HỮU ÍCH VÀ CÙNG NHAU THẢO LUẬN Kết nối:
VNK X
-
VNK groups
| Nhà Tài Trợ:
BhnongFood X
-
Bhnong groups
-
Đặt mua Bánh Bhnong
CÔNG NGHỆ
Công Nghệ Thông Tin
Web Development
Áp các kiểu cho các ASP.NET Web Control
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Trả lời chủ đề
Nội dung
<blockquote data-quote="hoangphuong2003" data-source="post: 70238" data-attributes="member: 1882"><p><strong>Có nhiều cách khác nhau để sử dụng các kiểu cho các Web control. Một trong các các thường dùng nhất là sử dụng các style sheet. Bạn có thể áp dụng các của của Web control một cách tự động và .NET Framework class library có cung cấp các lớp để thực hiện việc này.</strong></p><p></p><p>The System.Web.UI.WebControls.Style Class</p><p>Lớp Style được định nghĩa trong System.Web.UI.WebControls namespace để thể hiện kiểu của một Web server control. Lớp này cung cấp các thuộc tính có thể được sử dụng để áp dụng cho một hoặc nhiều Web control. Sử dụng các thuộc tính trên bạn có thể đặt màu background, foreground, độ rộng border và kiểu và kích thước của Web server controlcontrols to provide a common appearance. Using these properties, you can set the . Table 1 describes the Style class properties.</p><p></p><p><strong>Các thuộc tính của lớp Style</strong></p><p>BackColor Lấy và định màu background của Web server control</p><p>BorderColor Lấy và định màu border của Web server control</p><p>BorderStyle Lấy và định kiểu border của the Web server control</p><p>BorderWidth Lấy và định độ rộng border của Web server control</p><p>CssClass Lấy và định render CSS class của Web server control trên máy client.</p><p>Font Lấy và định các thuộc tính liên quan font của the Web server control</p><p>ForeColor Lấy và định màu foreground của Web server control.</p><p>Height Lấy và định chiều cao của Web server control.</p><p>Width Lấy và định chiều rộng của Web server control.</p><p>The System.Web.UI.WebControls.WebControl.ApplyStyle Method</p><p>Phương thức ApplyStyle của lớp WebControl dùng để áp kiểu một đối tượng Style cho một Web control. Phương thức này sử dụng đối số là một Style object.Ví dụ:</p><p>WebControl ctrl;</p><p>Style s;</p><p>ctrl.ApplyStyle(s);</p><p><strong>Ví dụ cụ thể:</strong></p><p>Bạn tạo một Web application sử dụng Visual Studio .NET và thêm 3 control vào Form - một Button, một TextBox, và một ListBox.</p><p>Bây giờ bạn tạo 2 phương thức - CreateStyle và SetControStyle. Phương thức CreateStyle lấy các đối số của như màu background , màu foreground, độ rộng border,và các kiểu font.</p><p>private Style CreateStyle(Color backClr, Color foreClr, int borderWidth, string fntName, int fntSize, bool fntBold, bool fntItalic</p><p>/* Bạn có thể thêm nhiều đối số */</p><p>{</p><p>Style s = new Style();</p><p>s.BackColor = backClr;</p><p>s.ForeColor = foreClr;</p><p>s.BorderWidth = borderWidth;</p><p>s.Font.Name = fntName;</p><p>s.Font.Size = fntSize;</p><p>s.Font.Bold = fntBold;</p><p>s.Font.Italic = fntItalic;</p><p>return s;</p><p>}</p><p>// Phương thức áp kiểu đến một Web cotrol</p><p>private void SetControlStyle(System.Web.UI.WebControls.WebControl ctrl,Style s)</p><p>{</p><p>ctrl.ApplyStyle(s);</p><p>}</p><p>private void Button1_Click(object sender, System.EventArgs e)</p><p>{</p><p>Style st = CreateStyle(Color.Green, Color.Yellow, 3,''Verdana'', 10, true, true);</p><p>SetControlStyle(TextBox1, st);</p><p>st = CreateStyle(Color.Red, Color.Black, 2,''Verdana'', 12, true, true);</p><p>SetControlStyle(SetStyleBtn, st);</p><p>st = CreateStyle(Color.Blue, Color.Yellow, 2,''Verdana'', 12, true, true);</p><p>SetControlStyle(ListBox1, st);</p><p>}</p><p>Theo : Diễn đàn tin học</p><p>Tham khảo thêm :</p><p><em>Ngôn ngữ lập trình ASP.NET</em></p><p><em>Tự học lập trình ASP.NET</em></p><p>Nguồn :<em>Áp các kiểu cho các ASP.NET Web Control</em></p><p>______________________</p><p><strong>Có thể bạn quan tâm:</strong></p><p>Kiến thức <em>học lập trình Java</em></p><p>Kiến thức về <em>tự học lập trình PHP</em></p></blockquote><p></p>
[QUOTE="hoangphuong2003, post: 70238, member: 1882"] [B]Có nhiều cách khác nhau để sử dụng các kiểu cho các Web control. Một trong các các thường dùng nhất là sử dụng các style sheet. Bạn có thể áp dụng các của của Web control một cách tự động và .NET Framework class library có cung cấp các lớp để thực hiện việc này.[/B] The System.Web.UI.WebControls.Style Class Lớp Style được định nghĩa trong System.Web.UI.WebControls namespace để thể hiện kiểu của một Web server control. Lớp này cung cấp các thuộc tính có thể được sử dụng để áp dụng cho một hoặc nhiều Web control. Sử dụng các thuộc tính trên bạn có thể đặt màu background, foreground, độ rộng border và kiểu và kích thước của Web server controlcontrols to provide a common appearance. Using these properties, you can set the . Table 1 describes the Style class properties. [B]Các thuộc tính của lớp Style[/B] BackColor Lấy và định màu background của Web server control BorderColor Lấy và định màu border của Web server control BorderStyle Lấy và định kiểu border của the Web server control BorderWidth Lấy và định độ rộng border của Web server control CssClass Lấy và định render CSS class của Web server control trên máy client. Font Lấy và định các thuộc tính liên quan font của the Web server control ForeColor Lấy và định màu foreground của Web server control. Height Lấy và định chiều cao của Web server control. Width Lấy và định chiều rộng của Web server control. The System.Web.UI.WebControls.WebControl.ApplyStyle Method Phương thức ApplyStyle của lớp WebControl dùng để áp kiểu một đối tượng Style cho một Web control. Phương thức này sử dụng đối số là một Style object.Ví dụ: WebControl ctrl; Style s; ctrl.ApplyStyle(s); [B]Ví dụ cụ thể:[/B] Bạn tạo một Web application sử dụng Visual Studio .NET và thêm 3 control vào Form - một Button, một TextBox, và một ListBox. Bây giờ bạn tạo 2 phương thức - CreateStyle và SetControStyle. Phương thức CreateStyle lấy các đối số của như màu background , màu foreground, độ rộng border,và các kiểu font. private Style CreateStyle(Color backClr, Color foreClr, int borderWidth, string fntName, int fntSize, bool fntBold, bool fntItalic /* Bạn có thể thêm nhiều đối số */ { Style s = new Style(); s.BackColor = backClr; s.ForeColor = foreClr; s.BorderWidth = borderWidth; s.Font.Name = fntName; s.Font.Size = fntSize; s.Font.Bold = fntBold; s.Font.Italic = fntItalic; return s; } // Phương thức áp kiểu đến một Web cotrol private void SetControlStyle(System.Web.UI.WebControls.WebControl ctrl,Style s) { ctrl.ApplyStyle(s); } private void Button1_Click(object sender, System.EventArgs e) { Style st = CreateStyle(Color.Green, Color.Yellow, 3,''Verdana'', 10, true, true); SetControlStyle(TextBox1, st); st = CreateStyle(Color.Red, Color.Black, 2,''Verdana'', 12, true, true); SetControlStyle(SetStyleBtn, st); st = CreateStyle(Color.Blue, Color.Yellow, 2,''Verdana'', 12, true, true); SetControlStyle(ListBox1, st); } Theo : Diễn đàn tin học Tham khảo thêm : [I]Ngôn ngữ lập trình ASP.NET[/I] [I]Tự học lập trình ASP.NET[/I] Nguồn :[I]Áp các kiểu cho các ASP.NET Web Control[/I] ______________________ [B]Có thể bạn quan tâm:[/B] Kiến thức [I]học lập trình Java[/I] Kiến thức về [I]tự học lập trình PHP[/I] [/QUOTE]
Tên
Mã xác nhận
Gửi trả lời
CÔNG NGHỆ
Công Nghệ Thông Tin
Web Development
Áp các kiểu cho các ASP.NET Web Control
Top