主题:[讨论]关于自定义控件问题,请各位指点!
代码如下:
namespace test24
{
using System;
using System.Web;
using System.Web.UI;
/// <summary>
/// WebUserControl1 的摘要说明。
public enum MessageStyle
{
Normal,
Italic,
Bold,
ItalicandBold,
}
public class Style
{
private MessageStyle _messageStyle;
private System.String _Color;
public Style(MessageStyle style, System.String color)
{
_messageStyle = style;
_Color = color;
}
public String Color
{
get
{
return _Color;
}
set
{
_Color = value;
}
}
public MessageStyle messageStyle
{
get
{
return _messageStyle;
}
set
{
_messageStyle = value;
}
}
}
public class firstcomponent:Control
{
private String _message;
public String Message
{
get
{
return _message;
}
set
{
_message = value;
}
}
private Style _Style = new Style(MessageStyle.Normal, "black");
public Style Style
{
get
{
return _Style;
}
set
{
_Style = value;
}
}
protected override void Render(HtmlTextWriter output)
{
string StartStyle = null;
string EndStyle = null;
switch(_Style.messageStyle)
{
case MessageStyle.Normal:
StartStyle = "";
EndStyle = "";
break;
case MessageStyle.Bold:
StartStyle = "<B>";
EndStyle = "</B>";
break;
case MessageStyle.Italic:
StartStyle = "<I>";
EndStyle = "</I>";
break;
case MessageStyle.ItalicandBold:
StartStyle = "<I><B>";
EndStyle = "</B></I>";
break;
}
output.Write(StartStyle + _message + EndStyle);
}
}
}
出错如下:
“/test24”应用程序中的服务器错误。
--------------------------------------------------------------------------------
分析器错误
说明: 在分析向此请求提供服务所需资源时出错。请检查下列特定分析错误详细信息并适当地修改源文件。
分析器错误信息: 未能加载类型“test24.WebForm1”。
源错误:
行 1: <%@ Register TagPrefix="test24" Namespace="test24" Assembly="test24"%>
[color=FF0000][color=008080][color=0000FF][color=FF0000]行 2: <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="test24.WebForm1" %>[/color][/color][/color][/color]行 3: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
行 4: <HTML>
namespace test24
{
using System;
using System.Web;
using System.Web.UI;
/// <summary>
/// WebUserControl1 的摘要说明。
public enum MessageStyle
{
Normal,
Italic,
Bold,
ItalicandBold,
}
public class Style
{
private MessageStyle _messageStyle;
private System.String _Color;
public Style(MessageStyle style, System.String color)
{
_messageStyle = style;
_Color = color;
}
public String Color
{
get
{
return _Color;
}
set
{
_Color = value;
}
}
public MessageStyle messageStyle
{
get
{
return _messageStyle;
}
set
{
_messageStyle = value;
}
}
}
public class firstcomponent:Control
{
private String _message;
public String Message
{
get
{
return _message;
}
set
{
_message = value;
}
}
private Style _Style = new Style(MessageStyle.Normal, "black");
public Style Style
{
get
{
return _Style;
}
set
{
_Style = value;
}
}
protected override void Render(HtmlTextWriter output)
{
string StartStyle = null;
string EndStyle = null;
switch(_Style.messageStyle)
{
case MessageStyle.Normal:
StartStyle = "";
EndStyle = "";
break;
case MessageStyle.Bold:
StartStyle = "<B>";
EndStyle = "</B>";
break;
case MessageStyle.Italic:
StartStyle = "<I>";
EndStyle = "</I>";
break;
case MessageStyle.ItalicandBold:
StartStyle = "<I><B>";
EndStyle = "</B></I>";
break;
}
output.Write(StartStyle + _message + EndStyle);
}
}
}
出错如下:
“/test24”应用程序中的服务器错误。
--------------------------------------------------------------------------------
分析器错误
说明: 在分析向此请求提供服务所需资源时出错。请检查下列特定分析错误详细信息并适当地修改源文件。
分析器错误信息: 未能加载类型“test24.WebForm1”。
源错误:
行 1: <%@ Register TagPrefix="test24" Namespace="test24" Assembly="test24"%>
[color=FF0000][color=008080][color=0000FF][color=FF0000]行 2: <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="test24.WebForm1" %>[/color][/color][/color][/color]行 3: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
行 4: <HTML>