Composite webcontrol and postback

G

George Ionescu

Hello all,

while trying to develop a composite webcontrol (which has, among other
things two textboxes and no submit buttons) I've faced the following
problem:

how can I read webcontrol's texboxes values, how can it pass data posted
from the client (the post is done with a command button on the page which
hosts the control)

I've looked into IPostBackDataHandler.LoadPostData, but it doesn't get
fired.

Any examples, if possible.

Thank you.
Regards,
George Ionescu
 
T

Teemu Keiski

Hi,

if you create the child controls in overridden CreateChildControls and you
implement INamingContainer in the composite control this stuff is already
done for you (I mean postback data handling for textBoxes and so on)

You can get the text values via Text property of the child TextBoxes. There
shouldn't be any need to get to the middle of the postback data processing
of TextBoxes as they are child controls and handle the processing
independently. You shouldn't be interested in that but instead you just pick
the values from the controls via relevant properties (or by say attaching
event handlers, for example to TextChanged events of TextBoxes, to get
informed when the value changes)

But if you for a reason or another absolutely want to get to the postback
data processing, you need to put Page.RegisterRequiresPostBack call on your
composite control's OnPreRender method to make sure
IPostBackDataHandler.LoadPostData is called for your composite control on
postback (this way it will be called for your composite control even if it
doesn't post anything itself e.g have something on form post collection)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top