自定义控件(dll)如何才有能子控件的代码提示? 我已经做了一个控件,能够在aspx页面实现:但问题是每次使用都必须自己输入子控件的标签 <TemplateItem>,请问怎么才能实现如:这样的代码提示?PS:C#,VS2008 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 比如我们在用 Repeater 控件的时候,建立模板控件,只需要在 <asp:Repeater runat="server" id="rpt"> 这行后面回车然后输入一个 < ,系统自动会展开一个代码提示框,让你选择AlternatingItemTemlateFooterTemplateHeaderTemplateItemTemplateSeparatorTemplate这几项,这样就无需自己去输入,也不需要记住这些子控件的标签。现在我建立的控件有个名为 TemplateItem 的标签,希望在输入 < 系统能够提示这个标签出来,(如果有更多的的子控件标签就可以选择),免得每次都要自己来输入。明白我的意思了吗?谢谢! 唉...copy 给你vs帮助示例.// VacationHome.csusing System;using System.ComponentModel;using System.Drawing;using System.Security.Permissions;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.Design;namespace Samples.AspNet.CS.Controls{ [ AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal), Designer(typeof(VacationHomeDesigner)), DefaultProperty("Title"), ToolboxData( "<{0}:VacationHome runat=\"server\"> </{0}:VacationHome>"), ] public class VacationHome : CompositeControl { private ITemplate templateValue; private TemplateOwner ownerValue; [ Bindable(true), Category("Data"), DefaultValue(""), Description("Caption") ] public virtual string Caption { get { string s = (string)ViewState["Caption"]; return (s == null) ? String.Empty : s; } set { ViewState["Caption"] = value; } } [ Browsable(false), DesignerSerializationVisibility( DesignerSerializationVisibility.Hidden) ] public TemplateOwner Owner { get { return ownerValue; } } [ Browsable(false), PersistenceMode(PersistenceMode.InnerProperty), DefaultValue(typeof(ITemplate), ""), Description("Control template"), TemplateContainer(typeof(VacationHome)) ] public virtual ITemplate Template { get { return templateValue; } set { templateValue = value; } } [ Bindable(true), Category("Data"), DefaultValue(""), Description("Title"), Localizable(true) ] public virtual string Title { get { string s = (string)ViewState["Title"]; return (s == null) ? String.Empty : s; } set { ViewState["Title"] = value; } } protected override void CreateChildControls() { Controls.Clear(); ownerValue = new TemplateOwner(); ITemplate temp = templateValue; if (temp == null) { temp = new DefaultTemplate(); } temp.InstantiateIn(ownerValue); this.Controls.Add(ownerValue); } public override void DataBind() { CreateChildControls(); ChildControlsCreated = true; base.DataBind(); } } [ ToolboxItem(false) ] public class TemplateOwner : WebControl { } #region DefaultTemplate sealed class DefaultTemplate : ITemplate { void ITemplate.InstantiateIn(Control owner) { Label title = new Label(); title.DataBinding += new EventHandler(title_DataBinding); LiteralControl linebreak = new LiteralControl("<br/>"); Label caption = new Label(); caption.DataBinding += new EventHandler(caption_DataBinding); owner.Controls.Add(title); owner.Controls.Add(linebreak); owner.Controls.Add(caption); } void caption_DataBinding(object sender, EventArgs e) { Label source = (Label)sender; VacationHome container = (VacationHome)(source.NamingContainer); source.Text = container.Caption; } void title_DataBinding(object sender, EventArgs e) { Label source = (Label)sender; VacationHome container = (VacationHome)(source.NamingContainer); source.Text = container.Title; } } #endregion public class VacationHomeDesigner : ControlDesigner { public override void Initialize(IComponent Component) { base.Initialize(Component); SetViewFlags(ViewFlags.TemplateEditing, true); } public override string GetDesignTimeHtml() { return "<span>This is design-time HTML</span>"; } public override TemplateGroupCollection TemplateGroups { get { TemplateGroupCollection collection = new TemplateGroupCollection(); TemplateGroup group; TemplateDefinition template; VacationHome control; control = (VacationHome)Component; group = new TemplateGroup("Item"); template = new TemplateDefinition(this, "Template", control, "Template", true); group.AddTemplateDefinition(template); collection.Add(group); return collection; } } }} 求救!通过javascript调用web service出错 如何让一个验证控件验证两个textbox? 怎么实现最近访问链接 如何在cs文件中修改aspx中的代码? 如何让gridview里的数据以不同的背景色显示? 怎么注册.net2.0 询问? 各位大神,求指导啊!!! 请教如何求时间差? The underlying connection was closed: An unexpected error occurred on a receive. “刷新”和“回发”肯定有区别!自己做了一个例子 CMS到底什么用?怎么和VS2005结合使用啊
<asp:Repeater runat="server" id="rpt"> 这行后面回车然后输入一个 < ,系统自动会展开一个代码提示框,让你选择
AlternatingItemTemlate
FooterTemplate
HeaderTemplate
ItemTemplate
SeparatorTemplate
这几项,这样就无需自己去输入,也不需要记住这些子控件的标签。现在我建立的控件有个名为 TemplateItem 的标签,希望在输入 < 系统能够提示这个标签出来,(如果有更多的的子控件标签就可以选择),免得每次都要自己来输入。明白我的意思了吗?
谢谢!
using System;
using System.ComponentModel;
using System.Drawing;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.Design;namespace Samples.AspNet.CS.Controls
{
[
AspNetHostingPermission(SecurityAction.InheritanceDemand,
Level=AspNetHostingPermissionLevel.Minimal),
AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal),
Designer(typeof(VacationHomeDesigner)),
DefaultProperty("Title"),
ToolboxData(
"<{0}:VacationHome runat=\"server\"> </{0}:VacationHome>"),
]
public class VacationHome : CompositeControl
{
private ITemplate templateValue;
private TemplateOwner ownerValue; [
Bindable(true),
Category("Data"),
DefaultValue(""),
Description("Caption")
]
public virtual string Caption
{
get
{
string s = (string)ViewState["Caption"];
return (s == null) ? String.Empty : s;
}
set
{
ViewState["Caption"] = value;
}
} [
Browsable(false),
DesignerSerializationVisibility(
DesignerSerializationVisibility.Hidden)
]
public TemplateOwner Owner
{
get
{
return ownerValue;
}
} [
Browsable(false),
PersistenceMode(PersistenceMode.InnerProperty),
DefaultValue(typeof(ITemplate), ""),
Description("Control template"),
TemplateContainer(typeof(VacationHome))
]
public virtual ITemplate Template
{
get
{
return templateValue;
}
set
{
templateValue = value;
}
} [
Bindable(true),
Category("Data"),
DefaultValue(""),
Description("Title"),
Localizable(true)
]
public virtual string Title
{
get
{
string s = (string)ViewState["Title"];
return (s == null) ? String.Empty : s;
}
set
{
ViewState["Title"] = value;
}
} protected override void CreateChildControls()
{
Controls.Clear();
ownerValue = new TemplateOwner(); ITemplate temp = templateValue;
if (temp == null)
{
temp = new DefaultTemplate();
} temp.InstantiateIn(ownerValue);
this.Controls.Add(ownerValue);
} public override void DataBind()
{
CreateChildControls();
ChildControlsCreated = true;
base.DataBind();
} } [
ToolboxItem(false)
]
public class TemplateOwner : WebControl
{
} #region DefaultTemplate
sealed class DefaultTemplate : ITemplate
{
void ITemplate.InstantiateIn(Control owner)
{
Label title = new Label();
title.DataBinding += new EventHandler(title_DataBinding); LiteralControl linebreak = new LiteralControl("<br/>"); Label caption = new Label();
caption.DataBinding
+= new EventHandler(caption_DataBinding); owner.Controls.Add(title);
owner.Controls.Add(linebreak);
owner.Controls.Add(caption); } void caption_DataBinding(object sender, EventArgs e)
{
Label source = (Label)sender;
VacationHome container =
(VacationHome)(source.NamingContainer);
source.Text = container.Caption;
} void title_DataBinding(object sender, EventArgs e)
{
Label source = (Label)sender;
VacationHome container =
(VacationHome)(source.NamingContainer);
source.Text = container.Title;
}
}
#endregion
public class VacationHomeDesigner : ControlDesigner
{ public override void Initialize(IComponent Component)
{
base.Initialize(Component);
SetViewFlags(ViewFlags.TemplateEditing, true);
} public override string GetDesignTimeHtml()
{
return "<span>This is design-time HTML</span>";
} public override TemplateGroupCollection TemplateGroups
{
get {
TemplateGroupCollection collection = new TemplateGroupCollection();
TemplateGroup group;
TemplateDefinition template;
VacationHome control; control = (VacationHome)Component;
group = new TemplateGroup("Item");
template = new TemplateDefinition(this, "Template", control, "Template", true);
group.AddTemplateDefinition(template);
collection.Add(group);
return collection;
}
}
}}