ASP.NET用户控件类库 [英] ASP.NET UserControl class library

查看:104
本文介绍了ASP.NET用户控件类库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能创建包含用户控件,所以我可以重新使用它们类库?如果是这样,怎么样?被标记编译.dll文件?感谢您的帮助!

Is it possible to create class libraries that contain UserControls so I can reuse them? If so, how? Is the markup compiled with the .dll? Thanks for any help!

推荐答案

更新:我是对我的使用pre-编译的用户控制,你会在用户控制提示。

Update: I was right on my hint on using the pre-compiled user control as you would an user control.

有关如何,请参阅打开一个的.ascx用户控件成一步一步一个可再发行自定义控件

有没有必要在这个项目在这里您可以使用它的任何.ascx文件,所以这个比赛正是你所期待的。

There is no need for any .ascx files in the project where you'll use it, so this matches exactly what you were looking for.


用户控件并不意味着跨站点,使用自定义服务器控件被重用来代替。

User Controls aren't meant to be reused across sites, use custom server controls instead.

您可以使用现有的控件组成服务器控件,并设置它的所有这样你就可以通过样式CSS。

You can compose the server controls using existing controls, and set it up all so you can style through css.

如果您仍然要为用户控制的方法,尝试什么鲍勃在答复中提到。我还没有与用户控件做这件事,但我希望能够用这种方法的输出,就像您使用自定义服务器控件。

If you are still going for the user control approach, try what Bob mentioned in the answer. I haven't done it with user controls, but I would expect to be able to use the output of that approach like you would use a custom server control.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls"%>
...
<aspSample:WelcomeLabel Text="Hello" NameForAnonymousUser="Guest" 
   ID="WelcomeLabel1" runat="server" BackColor="Wheat" ForeColor="SaddleBrown" />

诗。如果不工作,他提供的链接告诉你的ASCX文件复制反正,所以这不会是你正在寻找i.e.try上述&放大器;如果不坚持自定义服务器控件。

Ps. if that doesn't work, the link that he provided tells you to copy the ascx files anyway, so that wouldn't be what you were looking for i.e.try the above & if not stick to custom server controls.

这篇关于ASP.NET用户控件类库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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