Kuldeep Shige
Kuldeep Shige

Reputation: 453

how to get one ascx controls value from another ascx

I have Family.aspx page which contains a parent.ascx user control.

In parent.ascx contain two different user controls namely childA.ascx, childB.ascx and other five textboxes. Applying some logic I make child controls visible true or false. In ChildA and childB user control contain five textbox controls equally.

In Parent.ascx.cs, I have SaveData method which saves entire data in DB. so the catch is how to get ChildA or ChildB textboxes values in parent.ascx.cs so I can call SaveData.

Upvotes: 0

Views: 1774

Answers (2)

Lukasz M
Lukasz M

Reputation: 5723

If ChildA and ChildB are your custom user controls, you can expose values retrieved from TextBox controls as public properties (with some additional processing, if needed) and then read those properties in Parent.ascx.cs.

Upvotes: 1

markzzz
markzzz

Reputation: 47945

You could store data in Session[] from the ChildA.ascx / ChildB.ascx. Than, when you call SaveData, you could manage the data as you want! Just an option, I really don't know the scenario of your web application.

Upvotes: 0

Related Questions