D
DKode
Hello,
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();
this.LoadPage("ctlStats","controls/stats.ascx");
}
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");
s.SaveData();
}
else if (t == TabClicked.Medication.ToString()) {
controls.medication m =
(controls.medication)Page.FindControl("ctlMedication");
}
}
}
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
Sean
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();
this.LoadPage("ctlStats","controls/stats.ascx");
}
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");
s.SaveData();
}
else if (t == TabClicked.Medication.ToString()) {
controls.medication m =
(controls.medication)Page.FindControl("ctlMedication");
}
}
}
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
Sean