如何将 Text 的默认值设置为“abc”?
public enum MessageType
{
Good,
Bad
}
public partial class Message : System.Web.UI.UserControl
{
public bool Visible { get; set; } // Is the error visible
public string Text { get; set; } // Text of the error message
public MessageType Type { get; set; } // Message type
protected void Page_Load(object sender, EventArgs e)
{
ErrorPanel.Visible = this.Visible;
ErrorMsg.Text = this.Text;
// Hide if nothing to display
if (this.Text == null)
this.Visible = false;
// Set correct CSS class
if (this.Type == MessageType.Good)
ErrorPanel.CssClass = "good-box";
else
ErrorPanel.CssClass = "bad-box";
}
}