I have a user control on my .aspx page. It contains two text boxes and two drop down lists. Now on button click event another user control has been added,but before partial post back occur, I want to store the data entered from the previous control into a session so that I can retrieve these data and can refill previously added user controls.
Now my problem is: I can find server controls placed inside user control, but i can't get their values. Please guide me how to deal with user controls in the case of partial post back
. I tried to handle every methods of page class like page_load
,page_prerender
and so on.. but in vain.
any suggestions please.
Thanks in advance.
What do you mean you can find the user controls?
Are you retrieving the values from the page?
You can wrap the textbox.text as a property of the user control
class Usercontrol1
{
public string TextBox1Text
{
get { return Textbox.Text; }
}
}
So if you would try something like Session["something"] = someusercontrol.TextBox1Text
the textbox has no value?
Also check this page
http://encosia.com/2007/10/24/are-you-making-these-3-common-aspnet-ajax-mistakes/
•Control events, such as Click and SelectedIndexChanged, fire after Load events.
•By using PreRender instead of Load, you can allow control events to be handled before your code executes.