The simplest custom control

zhaozj2021-02-16  57

ASP.NET provides a mechanism for custom controls, which generates a simple custom control method.

Generally, when the web page processing error occurs, the error message can be displayed on the page, or the ALERT prompt information of JavaScript can be prompted. One way to implement Alert in ASP.NET is to define a custom control. The PROMPTCONTROL for the small chicken is achieved, which is really the simplest custom control, :-)

[DefaultProperty ( "Message"), ToolboxData ( "<{0}: PromptControl runat = server>")] [Designer (typeof (PromptControlDesigner))] public class PromptControl: System.Web.UI.WebControls.WebControl {private string message ;

[Bindable (true), Category ( "Appearance"), DefaultValue ( "")] public string Message {get {return message;} set {message = value;}} protected override void Render (HtmlTextWriter output) {if (Message! = NULL && Message.Length> 0) {Output.write ("