child control button click postback problem

Discussion in 'ASP .Net' started by pearcewg, Mar 18, 2007.

  1. pearcewg

    pearcewg Guest

    All:

    I have a page with a form and fields on the form (checkboxes, grids,
    etc).
    This form contains a usercontrol which has a dynamic navigational menu
    of buttons.
    When a user clicks on one of the buttons in the usercontrol, it is
    intended to save the updates information on the parent form. This is
    done using a delegate/callback function to save the data. The
    callback works great, and the save method is called on the parent
    page.

    However, I have a problem. When the usercontrol button is clicked,
    the latest data in the parent form is not there (it is the data loaded
    from the database, not the changed data). All of the controls are
    like this (checkboxes, textboxes, etc).

    I've tried changing the order of when the callback occurs to see if
    the page lifecycle has anything to do with it, but no luck. I have a
    save button on the parent form, which does almost the same behavior
    and works perfectly.

    Is the issue that the usercontrol cannot see postback data, or that I
    have to do something explicit to post it to be seen by the user
    control?

    Sample of the code, with usercontrol displayed (uc1:pagesidemenu):
    >>>

    <body background=".\images\Left_Gradient.gif"
    MS_POSITIONING="GridLayout">
    <form id="frmBusinessNameAddr" method="post" runat="server">
    <uc1:pageheader id="PageHeader1" runat="server"></uc1:pageheader>
    <table cellSpacing="0" cellPadding="0" width="100%">
    <tr>
    <td vAlign="top" width="100">
    <uc1:pagesidemenu id="PageSideMenu1" runat="server"></
    uc1:pagesidemenu>
    </td>
    <<<

    Thanks in advance for any insight,
    pearcewg
     
    pearcewg, Mar 18, 2007
    #1
    1. Advertising

  2. pearcewg

    Just Me Guest

    Not sure what the answer is, but as an alternative, can you not use
    viewstate ?

    "pearcewg" <> wrote in message
    news:...
    > All:
    >
    > I have a page with a form and fields on the form (checkboxes, grids,
    > etc).
    > This form contains a usercontrol which has a dynamic navigational menu
    > of buttons.
    > When a user clicks on one of the buttons in the usercontrol, it is
    > intended to save the updates information on the parent form. This is
    > done using a delegate/callback function to save the data. The
    > callback works great, and the save method is called on the parent
    > page.
    >
    > However, I have a problem. When the usercontrol button is clicked,
    > the latest data in the parent form is not there (it is the data loaded
    > from the database, not the changed data). All of the controls are
    > like this (checkboxes, textboxes, etc).
    >
    > I've tried changing the order of when the callback occurs to see if
    > the page lifecycle has anything to do with it, but no luck. I have a
    > save button on the parent form, which does almost the same behavior
    > and works perfectly.
    >
    > Is the issue that the usercontrol cannot see postback data, or that I
    > have to do something explicit to post it to be seen by the user
    > control?
    >
    > Sample of the code, with usercontrol displayed (uc1:pagesidemenu):
    >>>>

    > <body background=".\images\Left_Gradient.gif"
    > MS_POSITIONING="GridLayout">
    > <form id="frmBusinessNameAddr" method="post" runat="server">
    > <uc1:pageheader id="PageHeader1" runat="server"></uc1:pageheader>
    > <table cellSpacing="0" cellPadding="0" width="100%">
    > <tr>
    > <td vAlign="top" width="100">
    > <uc1:pagesidemenu id="PageSideMenu1" runat="server"></
    > uc1:pagesidemenu>
    > </td>
    > <<<
    >
    > Thanks in advance for any insight,
    > pearcewg
    >
     
    Just Me, Mar 18, 2007
    #2
    1. Advertising

  3. pearcewg

    pearcewg Guest

    I'm still looking, no solution yet.

    I think it comes down to this question:
    When a dynamically generated button in a user control is clicked, it
    causes the user control to update, with updated viewstate.
    How do I get the parent page to update viewstate?
    Is there a way to specify the usercontrol to update parent page
    viewstate, through creation or invokation or something similar?
    Could raising a bubbled event fix this problem (technically, I don't
    need the user control to do this work...I just want the parent page to
    save it's posted data back).

    Has anyone else has this problem:
    UserControl contains dynamic buttons, which when clicked, lose
    viewstate/data changes on parent form of usercontrol.
     
    pearcewg, Mar 18, 2007
    #3
  4. pearcewg

    pearcewg Guest

    Just to followup:

    I've re-learned that UserControls in asp.net have their own viewspace,
    separate from the parent which contains them. As a result, a postback
    of the usercontrol does not cause a postback of the parent.
    I can understand this design, and will work with it, but it seems a
    little strange that I am going to implement the following workaround.

    I've gone ahead and removed the UserControl, and places the instance
    code into each page that contains the usercontrol. It feels
    good...going back all the way to 1985.

    For my own long term lessons, if anyone out there knows of a solution
    for this problem, please post it...

    Thanks,
    pearcewg
     
    pearcewg, Mar 21, 2007
    #4
    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:
    880
    Purvi T
    Oct 19, 2004
  2. Amy
    Replies:
    0
    Views:
    1,011
  3. Jeff Rodriguez
    Replies:
    23
    Views:
    1,159
    David Schwartz
    Dec 9, 2003
  4. debartsa
    Replies:
    1
    Views:
    264
    John Saunders
    Apr 23, 2004
  5. caldera

    Placeholder child of child control event problem.

    caldera, May 27, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    218
Loading...

Share This Page