B
Buzz
Okay, having the same problem many others are having.
Here is a simple example I cannot get to work:
-- using C#
a) Created an ASP.NET Web Project.
b) Added a Web Control Library project to the solution calling the project
CustomControlLibrary.
c) I've tried a few different things but this is the latest of what my
WebCustomControl1.cs file looks like this:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace CustomControlLibrary
{
/// <summary>
/// Summary description for WebCustomControl1.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]
public class WebCustomControl1 : System.Web.UI.WebControls.WebControl
{
private System.Web.UI.WebControls.CheckBox checkBox;
/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
protected override void Render(HtmlTextWriter output)
{
base.Render(output);
}
protected override void CreateChildControls()
{
checkBox = new CheckBox();
Controls.Add(checkBox);
checkBox.Text = "Confused";
base.CreateChildControls();
}
}
}
d) I compiled the solution and then added my CustomControlLibrary to the web
toolbox.
e) I dragged and dropped WebCustomControl1 onto WebForm1.aspx.
f) I also dragged and dropped a textbox and button onto WebForm1.aspx.
g) I run the solution. I see the checkbox, textbox and button.
h) I click the checkbox so it is checked, I type "a" in the textbox and then
I press the button.
i) The page posts back. I see the "a" in the textbox but the checkbox is now
unchecked.
What other code do I need to add to WebCustomControl1.cs so that the
checkbox remembers the user checked it?
Thanks,
Buzz
Here is a simple example I cannot get to work:
-- using C#
a) Created an ASP.NET Web Project.
b) Added a Web Control Library project to the solution calling the project
CustomControlLibrary.
c) I've tried a few different things but this is the latest of what my
WebCustomControl1.cs file looks like this:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace CustomControlLibrary
{
/// <summary>
/// Summary description for WebCustomControl1.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]
public class WebCustomControl1 : System.Web.UI.WebControls.WebControl
{
private System.Web.UI.WebControls.CheckBox checkBox;
/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
protected override void Render(HtmlTextWriter output)
{
base.Render(output);
}
protected override void CreateChildControls()
{
checkBox = new CheckBox();
Controls.Add(checkBox);
checkBox.Text = "Confused";
base.CreateChildControls();
}
}
}
d) I compiled the solution and then added my CustomControlLibrary to the web
toolbox.
e) I dragged and dropped WebCustomControl1 onto WebForm1.aspx.
f) I also dragged and dropped a textbox and button onto WebForm1.aspx.
g) I run the solution. I see the checkbox, textbox and button.
h) I click the checkbox so it is checked, I type "a" in the textbox and then
I press the button.
i) The page posts back. I see the "a" in the textbox but the checkbox is now
unchecked.
What other code do I need to add to WebCustomControl1.cs so that the
checkbox remembers the user checked it?
Thanks,
Buzz