Postback of User Controls

G

Guest

I have two user controls Control1 and Control2 (.ascx) dependent on each
others input.

When the Web Page containing this control gets posted back I have some logic
to determine a value in Control1 that is an input to Control2.I find that I
am unable to achieve this because the Control1 postback is only done after
the Web Page postback.How can I force Control1 postback to occur in the Web
Page postback.

Please help me understand the process
 
A

Alejandro Penate-Diaz

what do you mean by "Control1 postback is only done after the Web Page
postback" ?
Postback submits back all the values that resides inside webcontrols whose
"EnableViewState" property is set to true, and that includes all the
webcontrols inside your user controls. So you should be able to get those
values like: UserControl1.TextBoxt. Text

Hope that helps,
Alejandro Penate-Diaz.
 
M

Mona

Hello Vishwanathan,

Let's say we have two controls on a web form, one textbox and the other
label.
You want the text entered in the textbox to be displayed in the label on
postback of the web form.

You can write the following code in the second control's page:
Dim c1 As New Control1

c1 = CType(Page, WebForm1).Control11

Dim tb As New TextBox

tb = c1.txtInput

Label1.Text = tb.Text

This would cause the text to display in label on postback.

HTH

Mona[Grapecity]
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top