关于自定义控件,如何在编辑状态下获取页面控件的ID?

alf7927 2004-03-16 11:21:00
如果各位使用过验证控件,不难发现,验证控件会把当前页面的控件作为枚举型选项
在属性窗口中显示,以备用户选择应用。现在自定写了一个这种控件,要做如此功能,可否给些思路??比如我做了一个分页控件,在编辑状态下要有提拱选择当前页面被控制的DataGrid功能,请明示。在下不胜感谢。、。。。。
...全文
91 16 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
chinchy 2004-03-17
  • 打赏
  • 举报
回复
累一个字

http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=212648
alf7927 2004-03-17
  • 打赏
  • 举报
回复
喷血ing........噗..呜~~~~~~~
alf7927 2004-03-17
  • 打赏
  • 举报
回复
up到喷血........
mynewpc 2004-03-16
  • 打赏
  • 举报
回复
定义属性:
Dim _text1 As Control

<Bindable(True), Category("Appearance"), DefaultValue("")> Property [Tdatagrid]() As WebControls.DataGrid
Get
Return _text1
End Get

Set(ByVal Value As WebControls.DataGrid)
_text1 = Value
End Set
End Property
mynewpc 2004-03-16
  • 打赏
  • 举报
回复
Imports System.ComponentModel
Imports System.Web.UI

<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")> Public Class WebCustomControl1
Inherits System.Web.UI.WebControls.WebControl

Dim _text As String

<Bindable(True), Category("Appearance"), DefaultValue("")> Property [Text]() As String
Get
Return _text
End Get

Set(ByVal Value As String)
_text = Value
End Set
End Property

Dim _text1 As Control

<Bindable(True), Category("Appearance"), DefaultValue(""), ListBindable(True)> Property [Tdatagrid]() As WebControls.DataGrid
Get
Return _text1
End Get

Set(ByVal Value As WebControls.DataGrid)
_text1 = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
output.Write([Text])
End Sub

End Class
chinchy 2004-03-16
  • 打赏
  • 举报
回复

控件:

[
Description("当前的文本框有焦点时按回车触发的按钮"),
TypeConverter(typeof(InvokeControlConverter))
]
public string EnterInvokeControlID
{
get
{
}
set
{
}
}


TypeConverter:

public class InvokeControlConverter : System.ComponentModel.TypeConverter
{
public InvokeControlConverter()
{
}

public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}

public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
System.Collections.ArrayList buttonList=new System.Collections.ArrayList();
foreach(System.ComponentModel.IComponent componet in context.Container.Components)
{
if(componet.GetType().ToString()=="System.Web.UI.WebControls.Button")
{
buttonList.Add(((System.Web.UI.WebControls.Button)componet).ID);
}
}

buttonList.Sort();
return new StandardValuesCollection(buttonList.ToArray());
}

public override bool CanConvertFrom(ITypeDescriptorContext context,Type sourceType)
{
if(sourceType.ToString()=="System.String")
{
return true;
}
else
{
return base.CanConvertFrom(context, sourceType);
}
}

public override object ConvertFrom(ITypeDescriptorContext context,CultureInfo culture,object value)
{
if(value.GetType().ToString()=="System.String")
{
return value;
}
else
{
return base.ConvertFrom(context, culture, value);
}
}


}
alf7927 2004-03-16
  • 打赏
  • 举报
回复
就是在编辑状态下,可以动态的找到当关页面的一些控件作为特定属性的可选项。
SVG 2004-03-16
  • 打赏
  • 举报
回复
当前页面被控制的DataGrid功能

//==>什么意思?
alf7927 2004-03-16
  • 打赏
  • 举报
回复
我up again
alf7927 2004-03-16
  • 打赏
  • 举报
回复
up,没有人来啊
bpy_r 2004-03-16
  • 打赏
  • 举报
回复
gz
alf7927 2004-03-16
  • 打赏
  • 举报
回复
mynewpc(水中日月)的方法是可以找到控件作为选项的,但是其子选项中会有被控制项的一些属性。但是仅仅需是的是一些ID字串如何做到呢?
alf7927 2004-03-16
  • 打赏
  • 举报
回复
各位可不可以详细点说明啊??
alf7927 2004-03-16
  • 打赏
  • 举报
回复
to edobnet(oоОoоО)
???
athossmth 2004-03-16
  • 打赏
  • 举报
回复
高手,学习。
edobnet 2004-03-16
  • 打赏
  • 举报
回复
验证控件有enable属性的,设为false就不验证了

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧