473,506 Members | 17,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

user controls: design-time vs. programmatic behavior

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:

Controls.PackageInfo info =
(Controls.PackageInfo)LoadControl("~/controls/packageInfo.ascx");
info.ID = "ucPackageInfo";
phInfoPanel.Controls.Add(info);

....and it shows up. but ive discovered that the control's button's
event handler no longer works -- setting a breakpoint on it shows that
its never called. the hanlder is mapped to it via:

private void InitializeComponent()
{
this.btnSubmit.Click += new
System.EventHandler(this.btnSubmit_Click);
}

....which the debugger hits.

any ideas why it no longer handles itself??
thanks!
matt

May 19 '06 #1
1 1182
ok, found the problem. i was only adding the control on the page's
button click event... so when the control's button was clicked, it was
firstly re-loading the page -- sans user control; thus no control event
hanlder could follow.

the solution was to load the user control in the page_load, all the
time (but invisible). on the page's button click event, make it
visible. then when the control's button is clicked, it will fire its
events/handlers (since it now exists!).
matt

May 19 '06 #2

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

Similar topics

8
2578
by: Eric Veltman | last post by:
Hello everyone, I've posted this question before, but got no answer, so I'll try to reformulate the question, maybe it helps :-) By the way, this is not intended as the start of an ASP.NET...
0
1736
by: Kate | last post by:
Hi: Well, I finally jumped into User Controls and am immediately over my head. I have gone through the Help file pages and tutorials completely, getting a vague feeling what I want to do is...
3
4111
by: zlst | last post by:
Many technological innovations rely upon User Interface Design to elevate their technical complexity to a usable product. Technology alone may not win user acceptance and subsequent marketability....
10
2684
by: BBM | last post by:
Hi, I have been developing with C# User Controls and occasionally have a problem where I "lose" a control from the design surface of the User Control. The controls that I am using to build my...
1
2116
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new...
5
1604
by: Gopal Krish | last post by:
Wondering what's the pros and cons in creating reusable web controls using 1. User Controls 2. C# class that creates the controls programmatically Example, I want to develop a page menu...
1
1325
by: Josh | last post by:
I am trying to move some of my more common controls into user controls. However, I seem to have problems maintaining state of databound controls that are contained within user controls. On...
0
2265
by: jonelling | last post by:
I am having a problem where the page load event is not being fired for certain user controls that I load dynamically in placeholders. Here is what I'm doing in brief, with full test code supplied...
9
2590
by: abprules | last post by:
Can somehow tell me the best way for multi user development to occur in MS Access? The situation is: We are creating a new database for a small company. There are 2 of us who want to...
8
1685
by: | last post by:
I'm looking for some design guidance on a collection of projects I'm working on. The project involves a bunch of websites constructed out of a collection of user controls. Different user...
0
7105
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7308
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,...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5617
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,...
1
5037
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
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...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
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 ...
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.