Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > composite control and postback data change handling

Reply
Thread Tools

composite control and postback data change handling

 
 
Donal McWeeney
Guest
Posts: n/a
 
      10-12-2004
Hi,

I have a composite control that gets created dynamically and contains an
array of checkbox controls and an array of drop down list controls.

All the control postback and rendering works fine - however there is
something that I want to do that I cant figure out how to do.

In my OnLoad handler I was to examine the updated postback values and
populate a new data structure based on these values. I need to do this
before the postback events get raised.

However because the control is created dynamically the postback data does
not get set until the postback data second try event is ran - which is after
the onload event.

Is there a way to hook into this or is the only way to manually add changed
events for each of the control items.

Thanks

Donal


 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      10-13-2004
Hi Donal,

From your description, you're developing a custom web server
control(composite control) which will create all the sub controls(control
tree) dynamically. And currently you're wondering how to get the new posted
datas when the contorl is posted back and create new control tree structure
depending on the new values, yes?
If there're anything I didn't understanding correctly, please feel free to
let me know.

As for this problem, here are some of my suggestions:

Generally, as for such a composite control which create control tree
programmatically, I suggest that we put all the sub control's creation code
in the "CreateChildControls" method, this method will be called before the
Load event and also can be recalled in other events (no later than the
PreRender event) so as to adjust the control tree.
And for your problem, I think you can define some control properties which
is persisted in VIEWSTATE which determine how to create the control's
control tree(those sub controls) in the CreateChildControls method. Have
your control implement "IPostBackDataHandler" interface? If so, you can
try making use of the
"bool IPostBackDataHandler.LoadPostData(string postDataKey,
NameValueCollection postCollection)"
interface , this event is fired after LoadViewState and Load , so we can
get the new posted data collections in it and compare them with the old
values in the VIEWSTAET, if different ,replace the properties with the new
values. And you can recall the "CreateChildControls" method to restructure
your control hierarchy when some of that properites are changed (in that
property's accessor).

In addition, here is a former thread in the group discussing on create a
composite control which will adjust the control tree depending on the post
back values:

http://groups.google.com/groups?hl=z...rEHA.2340%40TK
2MSFTNGP11.phx.gbl

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
 
 
 
Donal McWeeney
Guest
Posts: n/a
 
      10-15-2004
Hi Steven,

Thanks for the info.

We dont implement the PostBackDataHandler interface in our composite control
as the child controls we create like textboxes etc implement this and their
values get set correctly on the postback.

If I implement the PostBackDataHandler on my composite control will the
child controls have performed postback processing at that stage? Or do I
have to do something in code to get them to perform postback data
processing?

Thanks

Donal





"Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Donal,
>
> From your description, you're developing a custom web server
> control(composite control) which will create all the sub controls(control
> tree) dynamically. And currently you're wondering how to get the new
> posted
> datas when the contorl is posted back and create new control tree
> structure
> depending on the new values, yes?
> If there're anything I didn't understanding correctly, please feel free to
> let me know.
>
> As for this problem, here are some of my suggestions:
>
> Generally, as for such a composite control which create control tree
> programmatically, I suggest that we put all the sub control's creation
> code
> in the "CreateChildControls" method, this method will be called before the
> Load event and also can be recalled in other events (no later than the
> PreRender event) so as to adjust the control tree.
> And for your problem, I think you can define some control properties which
> is persisted in VIEWSTATE which determine how to create the control's
> control tree(those sub controls) in the CreateChildControls method. Have
> your control implement "IPostBackDataHandler" interface? If so, you can
> try making use of the
> "bool IPostBackDataHandler.LoadPostData(string postDataKey,
> NameValueCollection postCollection)"
> interface , this event is fired after LoadViewState and Load , so we can
> get the new posted data collections in it and compare them with the old
> values in the VIEWSTAET, if different ,replace the properties with the new
> values. And you can recall the "CreateChildControls" method to restructure
> your control hierarchy when some of that properites are changed (in that
> property's accessor).
>
> In addition, here is a former thread in the group discussing on create a
> composite control which will adjust the control tree depending on the post
> back values:
>
> http://groups.google.com/groups?hl=z...rEHA.2340%40TK
> 2MSFTNGP11.phx.gbl
>
> Hope helps. Thanks.
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      10-18-2004
Hi Donal,

Thanks for the response. Yes, if we implement the PostBackDataHandler, we
need to manually do the things to update the control's data properties ,
also childrens. And after some further consideration, I think we don't
actually need to implement that (which may make the problem more complex).

Would you consider putting the post data handing in the post back events
and recreate the sub controls structures at that time? I still thinnk
that'll make the problem much easier.
If you have any other ideas or any further question, please feel free to
post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      10-26-2004
Hi Donal,

Have you got any further progresses or ideas on this issue? If there're
anything else we can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
Donal McWeeney
Guest
Posts: n/a
 
      10-27-2004
Hi Steven,

I think I'm ok at the moment... will let you know if there is anything else.

Thanks

Donal


 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      10-28-2004
Thanks for your followup Donal. Feel free to let me know if you have any
further questions later in your work.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
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
Composite control, postback and change control tree STech ASP .Net Web Controls 7 11-21-2005 06:20 AM
Losing Composite Control property that another Composite Control ... Chad ASP .Net Building Controls 0 02-01-2005 09:01 PM
Possible to create a composite control that has a child control that is a validator that validates the composite control itself? Jonathan Eric Miller ASP .Net Building Controls 2 07-22-2004 10:58 PM
Composite control with dynamic composite controls sleigh ASP .Net 1 02-12-2004 06:24 PM
sorting composite control data on postback Aaron Prohaska ASP .Net Building Controls 0 11-06-2003 12:41 AM



Advertisments