473,658 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

programmatic usercontrol woes

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.EventArg s e)
{
My.Controls.Res ultsPane results = new My.Controls.Res ultsPane();

results.SetIt() ;
}

resultsPane.asc x

<span class="lb01">Ti tle: </span>
<asp:TextBox ID="tbTitle" Runat="server"/>

resultsPane.asc x.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

May 18 '06 #1
2 1093
ah, ive been working w/ server controls too long... the syntax for user
control loading is different:

My.Controls.Res ultsPane results =
(My.Controls.Re sultsPane)LoadC ontrol("~/controls/resultsPane.asc x");

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

May 18 '06 #2
ah, ive been working w/ server controls too long... the syntax for user
control loading is different:

My.Controls.Res ultsPane results =
(My.Controls.Re sultsPane)LoadC ontrol("~/controls/resultsPane.asc x");

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

May 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1957
by: Raed Sawalha | last post by:
Hi, I have a strange problem with a usercontrol on a page. The usercontrol dispalyes three categories (From a database) when the user clicks a category they see all the products in a shop for that category, the results are paged 10 to a page and the user can page them. As this "Category" usercontrol hardly ever changes I wanted to setup up caching for it. However I realised that when the user clicks a ctageory it is selected and...
2
4628
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation for me! I apologize for the length of this posting, but I wanted to make sure that I get an answer other than "Hey man, just use LoadControl!", because this is not what I want. The Task: Isolate a collection of web forms which are created as
41
4288
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based on some initialization information obtained elsewhere. Basically, I'm going to create my own dynamic toolbar where the toolbarbuttons can change. I'm not using the VB toolbar because of limitations in changing things like backcolor (I can't get...
3
2155
by: Don | last post by:
I've created a custom UserControlwithin which I have placed a Panel. I've changed the Panel's "Modifier" property to Public so that it appears in the Properties Window of the UserControl. This way, I could modify the properties of the panel within the UserControl when I place a UserControl on a Form. Or so I thought. I can set the properties of the Panel within the UserControl via the Properties Window, but none of the changes made to...
12
2198
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control server. It "serves" back the required control (either WebControl or UserControl) based on the contents of an xml file. The code in the webform places each control in a TableCell. My problem is that the control server works as far as returning the...
9
14442
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it does not. The problem is that the webcontrols get created on the OnLoad event of the usercontrol and the event handlers are assigned at the same time. I have to click twice on the controls for the events to be raised, the first time nothing...
6
4160
by: Blaine Manyluk | last post by:
I have a very unusual request. I need to be able to generate reports and save them as TIF files, with full programmatic control. The application will provide the filenames. Each page of the report will be saved as a seperate file. All the user should have to do is press a button to generate the TIFs, without having to "touch the meat" of viewing the report, choosing a file path/name, answering prompts, etc.
1
1185
by: matt.delvecchio | last post by:
hello, ive got a usercontrol that has some textboxes, a button, and a handler routine for its button_click. when this usercontrol is dropped into a page via the designer, it functions as expected -- when the button is clicked its event handler loads up the routine and i do db stuff. however, i am now adding the control to the page programmatically (on a page's button click), via:
6
12128
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use binding like normal. The problem I am running into is that my UserControl ends up with a different BindingContext then the ParentForm it is contained in and thus all other controls on the parent form. (I want various controls on the form to...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.