Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > programmatic usercontrol woes

Reply
Thread Tools

programmatic usercontrol woes

 
 
matt.delvecchio@shell.com
Guest
Posts: n/a
 
      05-18-2006
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

 
Reply With Quote
 
 
 
 
matt.delvecchio@shell.com
Guest
Posts: n/a
 
      05-18-2006
ah, ive been working w/ server controls too long... the syntax for user
control loading is different:

My.Controls.ResultsPane results =
(My.Controls.ResultsPane)LoadControl("~/controls/resultsPane.ascx");

....then you can do stuff w/ it, add it to the page, etc.


matt

 
Reply With Quote
 
 
 
 
matt.delvecchio@shell.com
Guest
Posts: n/a
 
      05-18-2006
ah, ive been working w/ server controls too long... the syntax for user
control loading is different:

My.Controls.ResultsPane results =
(My.Controls.ResultsPane)LoadControl("~/controls/resultsPane.ascx");

....then you can do stuff w/ it, add it to the page, etc.


matt

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
programmatic usercontrol woes matt.delvecchio@shell.com ASP .Net Web Controls 2 05-18-2006 11:53 PM
programmatic usercontrol woes matt.delvecchio@shell.com ASP .Net 2 05-18-2006 11:53 PM
Access a control inside an usercontrol from another control inside another usercontrol nail ASP .Net 0 09-15-2004 03:55 PM
Can we use a usercontrol inside a usercontrol Rajesh Tiwari ASP .Net 0 08-12-2003 03:56 PM
Use LoadControl to load a usercontrol but the webcontrol in the usercontrol can not AutoPostBack huobazi ASP .Net 1 07-03-2003 03:14 AM



Advertisments