PlaceHolder Control Question...

Discussion in 'ASP .Net Web Controls' started by Ralph Krausse, Sep 16, 2004.

  1. I have a sample at http://68.162.218.198/PlaceHolderTest/WebForm1.aspx.
    I am trying to figure out how capture a button event when I
    dynamically place a web user control in a placeholder control. I have
    4 buttons that place a web user control in the placeholder, that all
    works find. YOu click on the button and you will see that it gets
    loaded. This web user control has a button in it but when I click on
    it, the event doesn't get captured even there is an event defined with
    in the web user control. When you click on the button in the Web User
    Control, there is code to change the label above the button. But when
    you click on it, the user control disappears. Now I can understand
    that because the page gets recreated so my questions. Do I have to
    remember that this user control was added and on any postback, put it
    back? and how can I capture the button click on the web user control.




    Thanks
    Ralph Krausse

    www.consiliumsoft.com
    Use the START button? Then you need CSFastRunII...
    A new kind of application launcher integrated in the taskbar!
    ScreenShot - http://www.consiliumsoft.com/ScreenShot.jpg
     
    Ralph Krausse, Sep 16, 2004
    #1
    1. Advertising

  2. Ralph Krausse

    smay Guest

    You must reload the control in the placeholder in order for the click event
    in the control's codebehind to fire.

    Private Sub Page_Load...
    If Not Page.IsPostBack Then
    If Not Me.ViewState("ctrlPath") Is Nothing Then
    PlaceHolder.Controls.Add(LoadControl(Me.ViewState("ctrlPath")));
    End If
    End If
    End Sub


    "Ralph Krausse" wrote:

    > I have a sample at http://68.162.218.198/PlaceHolderTest/WebForm1.aspx.
    > I am trying to figure out how capture a button event when I
    > dynamically place a web user control in a placeholder control. I have
    > 4 buttons that place a web user control in the placeholder, that all
    > works find. YOu click on the button and you will see that it gets
    > loaded. This web user control has a button in it but when I click on
    > it, the event doesn't get captured even there is an event defined with
    > in the web user control. When you click on the button in the Web User
    > Control, there is code to change the label above the button. But when
    > you click on it, the user control disappears. Now I can understand
    > that because the page gets recreated so my questions. Do I have to
    > remember that this user control was added and on any postback, put it
    > back? and how can I capture the button click on the web user control.
    >
    >
    >
    >
    > Thanks
    > Ralph Krausse
    >
    > www.consiliumsoft.com
    > Use the START button? Then you need CSFastRunII...
    > A new kind of application launcher integrated in the taskbar!
    > ScreenShot - http://www.consiliumsoft.com/ScreenShot.jpg
    >
     
    smay, Sep 16, 2004
    #2
    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. Dan
    Replies:
    1
    Views:
    5,420
    Christophe Gijbels
    Jan 4, 2004
  2. Chris Kettenbach

    Reference a control in a placeholder control

    Chris Kettenbach, Jun 28, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    449
    Chris Kettenbach
    Jun 28, 2005
  3. Dan
    Replies:
    5
    Views:
    363
  4. nail

    Build control in a placeholder or like a placeholder

    nail, Sep 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    346
  5. Dan
    Replies:
    3
    Views:
    822
    Alessandro Zifiglio
    Jan 21, 2004
Loading...

Share This Page