By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,696 Members | 2,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,696 IT Pros & Developers. It's quick & easy.

child control button click postback problem

P: n/a
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

Mar 18 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a

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

"pearcewg" <pe******@gmail.comwrote in message
news:11*********************@l75g2000hse.googlegro ups.com...
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

Mar 18 '07 #2

P: n/a
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.

Mar 18 '07 #3

P: n/a
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

Mar 21 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.