M
matt.delvecchio
hello,
i have a user control that works great, when its used as a design-time
controls. however, when i try to use it as a programmtic control, im
running into troubles.
the control is pretty simple: it has a textbox, and a grid. in my
webform, on button_click i call one of its methods to do stuff (like
bind data and set a value to the textbox), and it works great.
but, when i try to do this from a new programmatic instance of the
control, it breaks anytime i try binding data/text to its child
controls. ala:
webform.aspx.cs
private void btnSubmit_Click(object sender, System.EventArgs e)
{
My.Controls.ResultsPane results = new My.Controls.ResultsPane();
results.SetIt();
}
resultsPane.ascx
<span class="lb01">Title: </span>
<asp:TextBox ID="tbTitle" Runat="server"/>
resultsPane.ascx.cs
protected TextBox tbTitle;
public void SetIt()
{
//breaks -- Object reference not set to an instance of an object.
tbTitle.Text = "xxx";
}
....any idea whats up?? ive noticed that quickwatching the tbPackage
yields "<undefined value>", whereas i was expecting properties related
to the textbox.
thanks!
matt
i have a user control that works great, when its used as a design-time
controls. however, when i try to use it as a programmtic control, im
running into troubles.
the control is pretty simple: it has a textbox, and a grid. in my
webform, on button_click i call one of its methods to do stuff (like
bind data and set a value to the textbox), and it works great.
but, when i try to do this from a new programmatic instance of the
control, it breaks anytime i try binding data/text to its child
controls. ala:
webform.aspx.cs
private void btnSubmit_Click(object sender, System.EventArgs e)
{
My.Controls.ResultsPane results = new My.Controls.ResultsPane();
results.SetIt();
}
resultsPane.ascx
<span class="lb01">Title: </span>
<asp:TextBox ID="tbTitle" Runat="server"/>
resultsPane.ascx.cs
protected TextBox tbTitle;
public void SetIt()
{
//breaks -- Object reference not set to an instance of an object.
tbTitle.Text = "xxx";
}
....any idea whats up?? ive noticed that quickwatching the tbPackage
yields "<undefined value>", whereas i was expecting properties related
to the textbox.
thanks!
matt