Saving control postback data

Discussion in 'ASP .Net' started by DKode, Jun 22, 2005.

  1. DKode

    DKode Guest

    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
    DKode, Jun 22, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF1bCBL?=

    Data not saving during postback

    =?Utf-8?B?UGF1bCBL?=, Aug 16, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    627
    =?Utf-8?B?UGF1bCBL?=
    Aug 16, 2004
  2. John Kandell
    Replies:
    4
    Views:
    4,136
    eeebop
    Dec 10, 2004
  3. Luis Esteban Valencia
    Replies:
    0
    Views:
    2,486
    Luis Esteban Valencia
    Jan 6, 2005
  4. vignesh86

    Saving gridview data on postback

    vignesh86, Jul 21, 2010, in forum: .NET
    Replies:
    0
    Views:
    1,112
    vignesh86
    Jul 21, 2010
  5. Lovely Angel For You

    Saving Images While Saving ASP Pages !

    Lovely Angel For You, Oct 2, 2003, in forum: ASP General
    Replies:
    1
    Views:
    188
    Curt_C [MVP]
    Oct 3, 2003
Loading...

Share This Page