help with events (i'm new to this)

Discussion in 'ASP .Net Web Controls' started by Colin Robinson, Jun 24, 2004.

  1. I can see there is an issue with web user control events on postback but
    dont fully understand how to implement a solution.

    I have a button on my aspx page, when clicked it adds instances of my web
    user control to a placeholder, it looks ok visually but events in the
    usercontrol dont fire.How should I instatiate my usercontrol instances so
    that events within them fire as expected?

    I am currently using the sysntax on the clickevent of a button

    dim ocontrol as mycontrol = loadcontrol("~Mycontrol.asax")
    me.placeholder.controls.add(ocontrol)

    Cheers
    Colin Robinson, Jun 24, 2004
    #1
    1. Advertising

  2. Colin Robinson

    Teemu Keiski Guest

    Hi,

    user control instances would need to be loaded at the page_load (on postback
    request relative to the UC itself) so that they'd be able to raise postback
    events.

    One way around is to use a flag value (in ViewState collection) to indicate
    that control should be created (or how many controls should be created) on
    postback so that they could be loaded at the page_load.

    If you want to see a n example, go to:
    http://www.microsoft.com/mspress/books/companion/6578.asp#Companion Content
    (Code download for Microsoft® ASP.NET Coding Strategies with the Microsoft
    ASP.NET Team )

    See the code for chapter one and there 'DynamicTextBox.aspx', it gives you a
    good example.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke



    "Colin Robinson" <> wrote in message
    news:OLy%...
    > I can see there is an issue with web user control events on postback but
    > dont fully understand how to implement a solution.
    >
    > I have a button on my aspx page, when clicked it adds instances of my web
    > user control to a placeholder, it looks ok visually but events in the
    > usercontrol dont fire.How should I instatiate my usercontrol instances so
    > that events within them fire as expected?
    >
    > I am currently using the sysntax on the clickevent of a button
    >
    > dim ocontrol as mycontrol = loadcontrol("~Mycontrol.asax")
    > me.placeholder.controls.add(ocontrol)
    >
    > Cheers
    >
    >
    >
    >
    >
    >
    Teemu Keiski, Jun 25, 2004
    #2
    1. Advertising

  3. thanks,

    I set them up visible false in load thenchanged visibility as required


    "Teemu Keiski" <> wrote in message
    news:ev$N$...
    > Hi,
    >
    > user control instances would need to be loaded at the page_load (on

    postback
    > request relative to the UC itself) so that they'd be able to raise

    postback
    > events.
    >
    > One way around is to use a flag value (in ViewState collection) to

    indicate
    > that control should be created (or how many controls should be created) on
    > postback so that they could be loaded at the page_load.
    >
    > If you want to see a n example, go to:
    >

    http://www.microsoft.com/mspress/books/companion/6578.asp#Companion Content
    > (Code download for Microsoft® ASP.NET Coding Strategies with the Microsoft
    > ASP.NET Team )
    >
    > See the code for chapter one and there 'DynamicTextBox.aspx', it gives you

    a
    > good example.
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    > http://blogs.aspadvice.com/joteke
    >
    >
    >
    > "Colin Robinson" <> wrote in message
    > news:OLy%...
    > > I can see there is an issue with web user control events on postback but
    > > dont fully understand how to implement a solution.
    > >
    > > I have a button on my aspx page, when clicked it adds instances of my

    web
    > > user control to a placeholder, it looks ok visually but events in the
    > > usercontrol dont fire.How should I instatiate my usercontrol instances

    so
    > > that events within them fire as expected?
    > >
    > > I am currently using the sysntax on the clickevent of a button
    > >
    > > dim ocontrol as mycontrol = loadcontrol("~Mycontrol.asax")
    > > me.placeholder.controls.add(ocontrol)
    > >
    > > Cheers
    > >
    > >
    > >
    > >
    > >
    > >

    >
    >
    Colin Robinson, Jun 26, 2004
    #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. shiv
    Replies:
    0
    Views:
    474
  2. Alvin Bruney
    Replies:
    1
    Views:
    720
  3. =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=

    order of events - dynamic checkbox events

    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=, Aug 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    562
    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=
    Aug 17, 2005
  4. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    354
    Chris
    Aug 30, 2005
  5. Replies:
    2
    Views:
    450
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page