UserControl not capturing Button click event when loaded with PlaceHolder Control

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

  1. My UI is one table, 2 colums, one row. The cell on the left has a tree
    and the cell on the right has a placeholder control. When the user
    clicks on a tree item, I dynamically load the apporopiate user control
    into the PlaceHolder control using this code...

    objPlaceHolder.Controls.Clear();
    objPlaceHolder.Controls.Add(LoadControl("nnn.ascx"));

    where nnn.ascx is the appropiate control. On this user control I have
    a button and hander defined but when I click on the button, the
    handler NEVER gets called.

    I am not sure why this happens....

    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 15, 2004
    #1
    1. Advertising

  2. Ralph Krausse

    smay Guest

    RE: UserControl not capturing Button click event when loaded with Plac

    When the page reloads (due to the button click) you must reload the control
    in the placeholder in order for the click event in the control's codebehind
    to fire. You might want to save the path "nnn.ascx" in viewstate.

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



    "Ralph Krausse" wrote:

    > My UI is one table, 2 colums, one row. The cell on the left has a tree
    > and the cell on the right has a placeholder control. When the user
    > clicks on a tree item, I dynamically load the apporopiate user control
    > into the PlaceHolder control using this code...
    >
    > objPlaceHolder.Controls.Clear();
    > objPlaceHolder.Controls.Add(LoadControl("nnn.ascx"));
    >
    > where nnn.ascx is the appropiate control. On this user control I have
    > a button and hander defined but when I click on the button, the
    > handler NEVER gets called.
    >
    > I am not sure why this happens....
    >
    > 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

  3. Ralph Krausse

    smay Guest

    RE: UserControl not capturing Button click event when loaded with

    Just a view state variable so that you know the filename of the last control
    to be loaded into the placeholder.

    "gordingin" wrote:

    > Thanks and sorry for any dumb questions but what is "ctrlPath". Is this
    > my web user control?
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    >
     
    smay, Sep 16, 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. Purvi T
    Replies:
    0
    Views:
    858
    Purvi T
    Oct 19, 2004
  2. Amy
    Replies:
    0
    Views:
    993
  3. Max2006
    Replies:
    2
    Views:
    1,578
    Walter Wang [MSFT]
    Sep 19, 2007
  4. nail

    Build control in a placeholder or like a placeholder

    nail, Sep 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    345
  5. Ralph Krausse
    Replies:
    1
    Views:
    216
    John Saunders
    Sep 15, 2004
Loading...

Share This Page