Events in dynamically loaded user controls

Discussion in 'ASP .Net' started by Danny Bloodworth, Nov 20, 2003.

  1. 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?
     
    Danny Bloodworth, Nov 20, 2003
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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?
     
    Kevin Spencer, Nov 20, 2003
    #2
    1. Advertising

  3. Danny Bloodworth

    SSW Guest

    "Kevin Spencer" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    > > 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?

    >
    >
     
    SSW, Nov 21, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Jaffe
    Replies:
    0
    Views:
    1,190
    Peter Jaffe
    Feb 4, 2004
  2. Earl Teigrob
    Replies:
    1
    Views:
    7,716
    nfedin
    Feb 10, 2004
  3. Raed Sawalha
    Replies:
    1
    Views:
    615
    Karl Seguin
    Oct 7, 2004
  4. =?Utf-8?B?V291dGVy?=

    Dynamically Loaded controls loading other controls

    =?Utf-8?B?V291dGVy?=, Feb 27, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    501
    =?Utf-8?B?V291dGVy?=
    Feb 27, 2006
  5. =?Utf-8?B?Smlt?=
    Replies:
    2
    Views:
    610
    =?Utf-8?B?Smlt?=
    Aug 20, 2007
Loading...

Share This Page