Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > child control button click postback problem

Reply
Thread Tools

child control button click postback problem

 
 
pearcewg
Guest
Posts: n/a
 
      03-18-2007
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 (uc1agesidemenu):
>>>

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

Thanks in advance for any insight,
pearcewg

 
Reply With Quote
 
 
 
 
Just Me
Guest
Posts: n/a
 
      03-18-2007

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

"pearcewg" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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 (uc1agesidemenu):
>>>>

> <body background=".\images\Left_Gradient.gif"
> MS_POSITIONING="GridLayout">
> <form id="frmBusinessNameAddr" method="post" runat="server">
> <uc1ageheader id="PageHeader1" runat="server"></uc1ageheader>
> <table cellSpacing="0" cellPadding="0" width="100%">
> <tr>
> <td vAlign="top" width="100">
> <uc1agesidemenu id="PageSideMenu1" runat="server"></
> uc1agesidemenu>
> </td>
> <<<
>
> Thanks in advance for any insight,
> pearcewg
>



 
Reply With Quote
 
 
 
 
pearcewg
Guest
Posts: n/a
 
      03-18-2007
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.

 
Reply With Quote
 
pearcewg
Guest
Posts: n/a
 
      03-21-2007
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fire both event button click and textchanged when button is click and text is changed Amy ASP .Net 0 06-01-2006 02:33 PM
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Building Controls 1 05-28-2004 06:23 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM



Advertisments