当前位置:编程学习 > C#/ASP.NET >>

Web自定义控件属性求解?

求解:
在设计Web自定义控件时定义如下属性:
public class myControl : WebControl
{
private string imageUrl;
public string ImageUrl
{
    get
    {
        return imageUrl;
     }
    set
    {
        imageUrl = value;
    }
}
}
使用控件如下:
<asp:myControl runat='server' ImageUrl="image/id.gif"/>
但是当我输入ImageUrl后再输入'='号,怎么不会弹出那个对话框,让我选择ImageUrl? --------------------编程问答-------------------- [UITypeEditor(typeof(System.Drawing.Design.ImageEditor), typeof(UITypeEditor)
]
public string ImageUrl
{
    get
    {
        return imageUrl;
     }
    set
    {
        imageUrl = value;
    }
}
--------------------编程问答-------------------- 你可以调用openfiledialog在代码中使用 --------------------编程问答-------------------- 楼上正解,关注ing --------------------编程问答-------------------- 学习中~ --------------------编程问答-------------------- [UITypeEditor(typeof(System.Drawing.Design.ImageEditor),   typeof(UITypeEditor) 

--------------------编程问答-------------------- --------------------编程问答-------------------- 这是属性编辑器, 除此之外, 系统还提供了许多属性编辑器, 比如:

1. 多行下拉文本属性编辑器
  [Editor("System.ComponentModel.Design.MultilineStringEditor,System.Design", typeof(UITypeEditor))]
public string TxtEditor
{
    //... ...
}
2. 色值选择属性编辑器
[Editor("System.ComponentModel.Design.ColorEditor,System.Design", typeof(UITypeEditor))]
public Color ColorEditor
{
    //... ...
}
3.文件选择属性编辑器
[Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
//http://blog.csdn.net/ChengKing/archive/2008/08/18/2792440.aspx
public string FileName
{
    //... ...
}
4.目录选择属性编辑器
[Editor(typeof(FolderNameEditor), typeof(UITypeEditor))]
public string FolderNameEditor
{
    //... ...
}

5.连接字符串属性编辑器
[Editor(typeof(System.Web.UI.Design.ConnectionStringEditor), typeof(UITypeEditor))]
public string ConnectionStringEditor
{
    //... ...
}
6.用户控件对话框编辑器
[Editor(typeof(System.Web.UI.Design.UserControlFileEditor), typeof(UITypeEditor))]
public string UserControlFileEditor
{
    //... ...
}

等等还有许多.  除了使用系统提供的, 还可以自己定制自己的编辑器, 如:
1. 定制多类型集合属性编辑器
2. 定制模态属性编辑器
3. 定制下拉控件属性编辑器
等等. 

这章的完整内容及示例如下(大概在08年12月底会整理完并放到如下链接中):
http://blog.csdn.net/ChengKing/archive/2008/08/18/2792440.aspx

  
补充:.NET技术 ,  组件/控件开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,