最佳实践在asp.net使用户控件? [英] Best Practices for making user controls in asp.net?

查看:145
本文介绍了最佳实践在asp.net使用户控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是使用用户控件的最佳做法?我的用户控制通常是提交服务器上的数据形式,他们都是为了重复使用的网页。

在哪里CSS样式应该放在用户控件内?或者在aspx页面和这些样式应该在网页或外部CSS?

同样成功或faulure消息通常是页面的一部分。但是,在使用用户控件应用户contorl告诉结果或消息吊牌的页面应该是控制内?

还有什么别的使用用户控件,同时考虑?

解决方案
  1. 该网页是控制器和它做保存/编辑,因此它也应该有其显示结果的标签。

  2. 页和用户控件应该按以下方式进行通信

    • 页面 - >通过性能和功能的UC
    • UC - >页面通过活动

下面是一些相关信息: HTTP:// WWW 。codeproject.com / KB /用户控件/ Page_UserControl.aspx#3

What are the best practices in using user controls ? my user controls are usually forms that submit data on server and they are made to reuse in pages.

Where css styles should be placed inside user control ? or in aspx page and these styles should be in page or external css ?

Similarly success or faulure message is usually a part of page. But in using user controls should user contorl tell the page about result or message lable should be inside the control ?

Any thing else to consider while using user controls ?

解决方案

  1. The page is the controller and it's doing the saving/editing, therefore it also should have the label which shows result.

  2. Page and UserControls should communicate in the following way

    • Page -> UC via Properties and Functions
    • UC -> Page via Events

Here are some more infos: http://www.codeproject.com/KB/user-controls/Page_UserControl.aspx#3

这篇关于最佳实践在asp.net使用户控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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