المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : CompositeDataBoundControl designer crashes VS2008



C# Programming
05-06-2009, 06:54 PM
I'm building a very simple composite control and when use the designer to select a data source it crashes Visual Studio 2008.

Here is the code:


namespace WebControlDesigner {
[ToolboxData("")]
public class ControlWithTasks : CompositeDataBoundControl {

public ControlWithTasks() : base() { }

[Category("Apearance")]
[DefaultValue("Your Birthday")]
public string Prompt {
get { return (string)ViewState["Prompt"] ?? "Your Birthday"; }
set { ViewState["Prompt"] = value; }
}

[Category("Data")]
[Bindable(true)]
public DateTime Birthday {
get { return (DateTime?)ViewState["Birthday"] ?? DateTime.Now; }
set { ViewState["Birthday"] = value; }
}

protected override int CreateChildControls(IEnumerable pDataSource, bool pBinding) {
base.CreateChildControls();

Label vLabel = new Label();
vLabel.Text = Prompt;
vLabel.ForeColor = Color.Red;
this.Controls.Add(vLabel);

Literal vLiteral = new Literal();
vLiteral.Text = ": ";
this.Controls.Add(vLiteral);

TextBox vTextBox = new TextBox();
vTextBox.ID = "TextBox1";
vTextBox.Text = Birthday.ToString();
this.Controls.Add(vTextBox);

return 0;
}
}
}


It's an extremely simple control, and builds without error.
Here is the page that consumes it:






















It renders perfectly and display the designer menu correctly but if I create a data source or try to select a existing one it crashes VS2008. http://www.barakasoft.com/script/Forums/Images/smiley_OMG.gif http://www.barakasoft.com/script/Forums/Images/smiley_confused.gif
What is missing?
Please!! I need some help.