-罢工开始-谁能解释-罢工结束的目的-需要帮助来了解asp.net中用户控件的目的吗? [英] --Strike starts--Can anybody explains purpose of --Strike ends-- Need help understanding the purpose of User Controls in asp.net?

查看:84
本文介绍了-罢工开始-谁能解释-罢工结束的目的-需要帮助来了解asp.net中用户控件的目的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以解释需要帮助来了解asp.net中用户控件的用途吗?传统上是通过包含文件和网络类的组合来完成的.尽管这对于业务逻辑来说相当不错,但对于可视化组件却总是有些杂乱无章.例如,如果您想在许多不同的地方显示数据网格,并希望该网格具有相同的总体外观,但可以针对特定页面进行自定义,则可以剪切并粘贴HTML,使用的样式表,一个include文件,编写一些VBScript来即时生成HTML,或结合使用所有这些方法.

太乱了.在项目之间移动这些组件也可能很困难,因为始终存在确保变量名称不冲突的问题,确保包含文件仅包含一次(正确顺序).然后是将新控件绑定到现有代码中的整个问题.

ASP .NET通过引入用户控件解决了许多此类问题.这些是自包含的可视元素,可以以与传统固有HTML控件相同的方式放置在网页上,并且可以以类似的方式设置其属性.


Can anybody explains Need help understanding the purpose of User Controls in asp.net?

解决方案

In traditional ASP code reuse and encapulation was traditionally done using a combination of include files and web classes. While this worked reasonably well for business logic, it was always a little fiddly for visual components. For example, if you wanted to display a grid of data in many different places and have the grid have the same general look and feel, but be customisable for a particular page, then you either cut and pasted the HTML, used style sheets, used an include file, wrote some VBScript to generate the HTML on the fly, or used a combination of all these methods.

It was messy. It could also be difficult to move these components between projects because there was the ever present problem of ensuring that variable names didn''t conflict, that you had the include file included only once (and in the correct order). Then there was the whole issue of tying the new control into existing code.

ASP .NET solves many of these issues with the introduction of User Controls. These are self contained visual elements that can be placed on a web page in the same way as a tradition intrinsic HTML control, and can have their attributes set in a similar fashion.


这篇关于-罢工开始-谁能解释-罢工结束的目的-需要帮助来了解asp.net中用户控件的目的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆