473,326 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Events in dynamically loaded user controls

I have a usercontrol (login.ascx) that is very simple. It accepts
input through two textboxes, and then the user clicks an Imagebutton
to submit.

I have a parent form that checks the page security (security level
needed) against current user security (stored in the context object)
and

if user security >= level needed to view page then
dynamically loads a content control and displays content
else
dynamically loads the login control
end if

The problem is that when I dynamically load the login control (into an
HTML table cell BTW), the ImageButton_Click event will not fire. It
simply posts the page back to the browser.

I've spent the entire day reading newsgroup posts about things like
eventbubbling, adding handlers, etc., but so far I just don't get it.

Can someone give me a "VB" answer to allowing the login control's
imagebutton event to fire?
Nov 18 '05 #1
2 2146
In ASP.Net, you're working in a Stateless environment, which means that
State maintenance is handled through some rather complex workarounds. Each
PostBack of a WebForm is a fresh Request to the server, which has no memory
of the last Request. Each time the Page posts back, the classes in it must
be created anew. Therefore, if you dynamically add a control to a Page, and
expect to handle an event fired by the Page on the client, you must
re-create the control prior to the event handler's handling of the event
after the PostBack.

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Danny Bloodworth" <db*********@infinitechs.com> wrote in message
news:91**************************@posting.google.c om...
I have a usercontrol (login.ascx) that is very simple. It accepts
input through two textboxes, and then the user clicks an Imagebutton
to submit.

I have a parent form that checks the page security (security level
needed) against current user security (stored in the context object)
and

if user security >= level needed to view page then
dynamically loads a content control and displays content
else
dynamically loads the login control
end if

The problem is that when I dynamically load the login control (into an
HTML table cell BTW), the ImageButton_Click event will not fire. It
simply posts the page back to the browser.

I've spent the entire day reading newsgroup posts about things like
eventbubbling, adding handlers, etc., but so far I just don't get it.

Can someone give me a "VB" answer to allowing the login control's
imagebutton event to fire?

Nov 18 '05 #2
SSW

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:ej**************@TK2MSFTNGP12.phx.gbl...
In ASP.Net, you're working in a Stateless environment, which means that
State maintenance is handled through some rather complex workarounds. Each
PostBack of a WebForm is a fresh Request to the server, which has no memory of the last Request. Each time the Page posts back, the classes in it must
be created anew. Therefore, if you dynamically add a control to a Page, and expect to handle an event fired by the Page on the client, you must
re-create the control prior to the event handler's handling of the event
after the PostBack.

--
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Danny Bloodworth" <db*********@infinitechs.com> wrote in message
news:91**************************@posting.google.c om...
I have a usercontrol (login.ascx) that is very simple. It accepts
input through two textboxes, and then the user clicks an Imagebutton
to submit.

I have a parent form that checks the page security (security level
needed) against current user security (stored in the context object)
and

if user security >= level needed to view page then
dynamically loads a content control and displays content
else
dynamically loads the login control
end if

The problem is that when I dynamically load the login control (into an
HTML table cell BTW), the ImageButton_Click event will not fire. It
simply posts the page back to the browser.

I've spent the entire day reading newsgroup posts about things like
eventbubbling, adding handlers, etc., but so far I just don't get it.

Can someone give me a "VB" answer to allowing the login control's
imagebutton event to fire?


Nov 18 '05 #3

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

Similar topics

3
by: Kenton Smeltzer | last post by:
Hello All, I am having a problem with events and the addition of controls on a page I am developing. First let me tell you what I have tried and then maybe someone can see something I missed. ...
7
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
4
by: blue | last post by:
I have a drop-down list, a radio button list and a submit button. I'm adding these controls to a table and I'm adding the table to a Placeholder. I'm adding it to the Placeholder because I don't...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
1
by: Earl Teigrob | last post by:
PROBLEM: When a user control is loaded into a PlaceHolder control more than once, the events do not fire on the first click of a control on the dynamically loaded user control. In other words, the...
1
by: Josh | last post by:
Hi Guys, I have been having a big problem with trying to pass parameters into a user control when the user control is dynamically loaded into a placholder. I am developing in c#. I have get...
5
by: karthick raja | last post by:
Am experiencing a problem intercepting the events from controls added dynamically to a Placeholder control at runtime. Is there any way that I can write an event handler on the page which will be...
1
by: Raed Sawalha | last post by:
I am trying to sort a DataGrid in a user control that is programatically loaded when a link button is clicked. UC1 is loaded onto Page1.aspx after clicking a link button. No problem, loads fine....
6
by: hlubocky | last post by:
I thought I had a good grasp of the problem related to dynamically creating controls, but it appears that as my application grew in complexity, the problem has resurfaced. As I understand it, in...
2
by: =?Utf-8?B?SHV6ZWZh?= | last post by:
Hi, I am using a Multipage control with ASP.Net 1.1. The events for controls within the multipage are not getting fired. Any ideas why this would happen. It was working fine before i added...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.