自定义控件图标无法设置的问题
下面是自定义控件的代码:现在就是图标无设置。另外发现在工具箱中,此控件无法删除。不知是什么原因。
1
using System;2
using System.Collections.Specialized;3
using System.ComponentModel;4
using System.Drawing.Design;5
using System.Drawing.Imaging;6
using System.Globalization;7
using System.Security.Permissions;8
using System.Web;9
using System.Web.UI;10
using System.Web.UI.WebControls;11
using System.Drawing;12

13
namespace ControlTooImg14


{15
[ToolboxBitmap(typeof(MyTextBox))]16
//, "CustomControls.Resources.MyTextBox.bmp")17
18
[DefaultProperty("Text ")]19
[ToolboxData(" <{0}:MyTextBox runat=server> </{0}:MyTextBox> ")]20
public class MyTextBox : WebControl, IPostBackDataHandler21

{22
private static readonly object EventTextChanged;23
[Category("Action "), Description("TextBox_OnTextChanged ")]24
public event EventHandler TextChanged25

{26
add27

{28
base.Events.AddHandler(EventTextChanged, value);29
}30
remove31

{32
base.Events.RemoveHandler(EventTextChanged, value);33
}34
}35

36

37
[DefaultValue(" "), Localizable(true), Bindable(true, BindingDirection.TwoWay),38
Category("Appearance "), Description("TextBox_Text "),39
PersistenceMode(PersistenceMode.EncodedInnerDefaultProperty)]40
public string Text41

{42
get43

{44
String s = (String)ViewState["Text "];45
return ((s == null) ? String.Empty : s);46
}47

48
set49

{50
ViewState["Text "] = value;51
}52
}53

54
protected override void RenderContents(HtmlTextWriter writer)55

{56
//output.Write(Text);57
}58

59
protected override void Render(HtmlTextWriter writer)60

{61
writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID); 62
writer.AddAttribute(HtmlTextWriterAttribute.Type, "Text ");63
writer.AddAttribute(HtmlTextWriterAttribute.Value, this.Text);64
writer.AddAttribute(HtmlTextWriterAttribute.Onchange, Page.GetPostBackEventReference(this, "")); 65
writer.AddAttribute(HtmlTextWriterAttribute.Id, this.UniqueID);66
writer.RenderBeginTag(HtmlTextWriterTag.Input);67
writer.RenderEndTag();68
}69

70
71

72
[Category("Behavior "), DefaultValue(false), Themeable(false), Description("TextBox_AutoPostBack ")]73
public virtual bool AutoPostBack74

{75
get76

{77
object obj2 = this.ViewState["AutoPostBack "];78
if (obj2 != null)79

{80
return (bool)obj2;81
}82
return false;83
}84
set85

{86
this.ViewState["AutoPostBack "] = value;87
}88
}89

90
bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)91

{92
string text = this.Text;93
string str2 = postCollection[postDataKey];94
if (!text.Equals(str2, StringComparison.Ordinal))95

{96
this.Text = str2;97
return true;98
}99
return false;100
}101

102
void IPostBackDataHandler.RaisePostDataChangedEvent()103

{104
this.OnTextChanged(EventArgs.Empty);105
}106

107
protected virtual void OnTextChanged(EventArgs e)108

{109
EventHandler handler = (EventHandler)base.Events[EventTextChanged];110
if (handler != null)111

{112
handler(this, e);113
}114
}115
}116
}下面是截图:
1.用VS做的图标
2.将图标保存为和类同名文件存在项目中。并设置为嵌入资源
3。重新编译运行,控件的图标还是没有变。另外这个控件在工具箱中,为什么没有删除功能呀?
求高手解惑!
大道至简
浙公网安备 33010602011771号