By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,534 Members | 2,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,534 IT Pros & Developers. It's quick & easy.

Saving control postback data

P: n/a

I am trying to call a UserControl after postback to save data filled
out on that usercontrol to sql server.

The problem I am having is this, I have 2 LinkButtons that I have setup
as tabs on my app, the user fills out information on UserControl_1,
when they click a different tab, I want to load UserControl_2 and save
the data that was entered into UserControl_1.

When I try to call Page.FindControl("UserControl_1") or
Page.FindControl("UserControl_2") it returns a null reference to the
usercontrol that i am trying to save the data from.

Heres code from the Page_Load event of the Parent control:
private void Page_Load(object sender, System.EventArgs e) {
if (!IsPostBack) {
this._tabClicked = TabClicked.Main;
Session["tab"] = TabClicked.Main.ToString();
if (IsPostBack) {
// Save the current pages values
string t = (string)Session["tab"];
if (t == TabClicked.Main.ToString()) {
controls.stats s = (controls.stats)Page.FindControl("ctlStats");
else if (t == TabClicked.Medication.ToString()) {
controls.medication m =
(controls.medication)Page.FindControl("ctlMedicati on");


note: TabClicked is an ENUM, I am saving the value to Session so after
the user clicks a new tab, I can retrieve what was the previous tab
they were on.

Am I going about this the right way or am I way off base?

any help would be appreciated! Thanks


Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.