カスタムコントロールを別のWebコントロールから派生したJSONにシリアル化する方法を知っている人はいますか?基本クラスがシリアル化できないというエラーが表示され続けます。派生クラスのコードは次のとおりです
public class BaseWidget : CompositeControl
{
protected Label _lblHeader;
protected Button _editButton;
protected HtmlInputHidden _idField;
/// <summary>
/// The Unique identified that identifies this widget
/// </summary>
public int ControlID
{
get
{
EnsureChildControls();
int i = -1;
int.TryParse(_idField.Value, out i);
return i;
}
set
{
EnsureChildControls();
_idField.Value = value.ToString();
}
}
/// <summary>
/// Allow the user to edit the widget
/// </summary>
public bool AllowEdit
{
get;
set;
}
public string Title
{
get
{
EnsureChildControls();
return _lblHeader.Text;
}
set
{
EnsureChildControls();
_lblHeader.Text = value;
}
}
public string CallbackFunction
{
get;
set;
}
protected Panel Header
{
get;
set;
}
/// <summary>
/// The Main Control of the widget
/// </summary>
protected Panel Content
{
get;
set;
}
protected Panel Edit
{
get;
set;
}
protected Panel Body
{
get;
set;
}
/// <summary>
/// The tag that the control is associated with
/// </summary>
protected override HtmlTextWriterTag TagKey
{
get
{
return HtmlTextWriterTag.Li;
}
}
public BaseWidget()
{
this.ControlID = 0;
}}
実際には、基本クラスの属性をシリアル化する必要はありません。コントロールIDと関連するタイトルがシリアル化されている必要があります。Web Controlがシリアル化できない場合にこれを行う方法はありますか?WebControlクラスはシリアル化できないため、DataContractJsonSerializerとJavascriptSerializerを試してみましたが運が悪かったです。