Professional ASP.NET 1.1 [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Professional ASP.NET 1.1 [Electronic resources] - نسخه متنی

Alex Homeret

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Chapter 4 for more on user controls), all of the features shown can be pretty much applied to them.

A key benefit of user controls is that complex sections of the UI can be declared using only control declarations. In a server control, you'd have to write code to achieve this. Although not difficult, this can be time consuming–changing or maintaining it can take longer–and also is more error-prone.

Why Create Your Own Server Controls?


"Why create your own controls?" isn't really the right question to ask. Instead, the decision you have to make as an ASP.NET developer is whether you let ASP.NET build server controls automatically for you (by just building your sites using ASP.NET pages and/or user controls), or whether you take over some of the control creation yourself. In the latter case, you can build your site using a mixture of ASP.NET pages, user controls, and custom server controls.

Thus, there's no right answer to the original question. However, a few pointers should help you decide for yourself:



ASP.NET controls enable a fine-grained level of black-box reuse. ASP.NET user controls and pages can also provide this reuse, but since they are far more coarse-grained and typically have fixed UI traits (pages don't support templates, although user controls can), they are likely to provide far less reuse.



ASP.NET controls ultimately provide the most flexibility, but take longer to write and require more coding skill.



If you want a custom control, but are not 100% sure, start with a user control; you can always change it to become a custom control later. All the code you write will work as a control, but you will need to convert any HTML sections of your user control into code using control composition.



Only custom controls and user controls can be lookless, and therefore support templates. If you want people to be able to extend and manage your control's UI, use these control types.



User controls and custom controls can be written in different languages, and then used within the same hosting page. At present, only one language can be used directly within any single ASP.NET page.



Only custom controls are compiled. You may therefore want to use them if you need to protect your sourcecode.



/ 244