[英]ASP.NET user control designer support
I have a user control which when added to the markup via the Toolbox or manually typing <myNameSpc:myCtrl ...
I would like to spit out: 我有一个用户控件,当通过工具箱将其添加到标记中或手动键入
<myNameSpc:myCtrl ...
我<myNameSpc:myCtrl ...
出来:
<myNameSpc:myCtrl>
<template></template>
</myNameSpc:myCtrl>
I remember doing this for windows workflows and it involved implementing something like a TypeConverter and WorkflowXmlSerializer so it maybe possible for user controls as well I'd guess ? 我记得为Windows工作流执行此操作,它涉及实现诸如TypeConverter和WorkflowXmlSerializer之类的东西,因此我猜想用户控件也有可能吗? the only thing is that I don't have time to research this matter now, so I was wondering if anyone would be kind enough to point me in the right direction so that I don't have to dig deep into the designer serialization of VS (which I remember was a big pain).
唯一的事情是我现在没有时间研究这个问题,所以我想知道是否有人会友好地将我指向正确的方向,这样我就不必深入研究VS的设计师序列化了(我记得那是一个很大的痛苦)。
For your custom control, you can specify a ToolboxDataAttribute
which defines the default html that will be generated when you drag a control onto the design service. 对于您的自定义控件,您可以指定一个
ToolboxDataAttribute
,它定义将控件拖到设计服务上时将生成的默认html。 Eg: 例如:
[ToolboxData("<{0}:myCtrl runat="server"><template></template></{0}:myCtrl>")]
public class myCtrl : System.Web.UI.Control
{
}
For the manual generation you can create a Code Snippet . 对于手动生成,您可以创建一个代码片段 。 The best way to do that is find existing ASPX snippet and modify it to gen your control.
最好的方法是找到现有的ASPX代码段,然后对其进行修改以生成控件。 I'm assuming you are using VS 2010.
我假设您使用的是VS 2010。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.