473,327 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Saving control postback data

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("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

Sean

Nov 19 '05 #1
0 1110

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Igor Belagorudsky | last post by:
Hi, i am trying to analyze data submitted in a form but the problem is that when i try to create the controls in code (which is what i want to do), it throws an obect not found exception on...
2
by: Duwayne | last post by:
I am having lots of trouble with one of my user controls (ascx) not automatically loading postback data. An image on the aspx page starts the postback and the parent has no problem loading it's own...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
2
by: Paul K | last post by:
I have the user selecting a record on one page of the web app I'm working on. After they select a record, I save the record into a session variable and submit the main page (in another window). In...
1
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
4
by: Nemisis | last post by:
Hi everyone, I am wondering if anyone has tried the following saving values from a page to a database using CallBack? is this possible? Basically instead of pressing a button that contacts...
2
by: paulcis | last post by:
I am trying to produce a dynamic form from a database with unknown amount of records. I need to read the values and create a new textbox for each. I need to create the textboxes at page_init stage...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.