ASP.NET rookie needs help finding postback data

Discussion in 'ASP .Net' started by =?Utf-8?B?anJldHQ=?=, Sep 20, 2006.

  1. I'm new to ASP.NET and fairly inexperienced with web development in general,
    but I've been a professional software dev for over 10 years, C++, Unix and
    windows, C# the past 4 years.

    I've been working on a personal ASP.NET project, basically as a learning
    tool and I have a major issue which is really really getting on my nerves.

    I'm creating a web application in ASP.NET 2.0 which dynamically populates a
    table with text and text boxes. This table has two columns; in the left colum
    are fields labelling the text boxes on the right column.

    After post back, I cannot for the life of me find the values that were
    entered into the text boxes. When I turn tracing on, I see in the 'Form
    Collection' that my values have in fact been kept via ViewState, but when I
    go into the Table object, the 'rows' are empty.

    I'm sure this is going to be a difficult one to diagnose via this post as it
    appears to be pretty vague, bug perhaps if you can explain to me how to find
    a control by either the control ID or by the Unique ID? The Unique ID is
    shown in the trace output. I've tried using a debugger and examined the
    Table object in a watch window, but there are a million nodes on that.

    Please help!! This has been keeping me up at night. It seems like such a
    simple friggin thing.

    --
    Jaan
     
    =?Utf-8?B?anJldHQ=?=, Sep 20, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?anJldHQ=?=

    Jon Paal Guest

    http://samples.gotdotnet.com/quickstart/aspplus/doc/webformsintro.aspx



    "jrett" <> wrote in message news:...
    > I'm new to ASP.NET and fairly inexperienced with web development in general,
    > but I've been a professional software dev for over 10 years, C++, Unix and
    > windows, C# the past 4 years.
    >
    > I've been working on a personal ASP.NET project, basically as a learning
    > tool and I have a major issue which is really really getting on my nerves.
    >
    > I'm creating a web application in ASP.NET 2.0 which dynamically populates a
    > table with text and text boxes. This table has two columns; in the left colum
    > are fields labelling the text boxes on the right column.
    >
    > After post back, I cannot for the life of me find the values that were
    > entered into the text boxes. When I turn tracing on, I see in the 'Form
    > Collection' that my values have in fact been kept via ViewState, but when I
    > go into the Table object, the 'rows' are empty.
    >
    > I'm sure this is going to be a difficult one to diagnose via this post as it
    > appears to be pretty vague, bug perhaps if you can explain to me how to find
    > a control by either the control ID or by the Unique ID? The Unique ID is
    > shown in the trace output. I've tried using a debugger and examined the
    > Table object in a watch window, but there are a million nodes on that.
    >
    > Please help!! This has been keeping me up at night. It seems like such a
    > simple friggin thing.
    >
    > --
    > Jaan
     
    Jon Paal, Sep 20, 2006
    #2
    1. Advertising

  3. Hi Jann,

    What kind of table are you using? A plain HTML table? A datagrid? An ASP.NET
    table?

    It would help to see the code that isn't working.

    Ken
    Microsoft MVP [ASP.NET]

    "jrett" <> wrote in message
    news:...
    > I'm new to ASP.NET and fairly inexperienced with web development in
    > general,
    > but I've been a professional software dev for over 10 years, C++, Unix and
    > windows, C# the past 4 years.
    >
    > I've been working on a personal ASP.NET project, basically as a learning
    > tool and I have a major issue which is really really getting on my nerves.
    >
    > I'm creating a web application in ASP.NET 2.0 which dynamically populates
    > a
    > table with text and text boxes. This table has two columns; in the left
    > colum
    > are fields labelling the text boxes on the right column.
    >
    > After post back, I cannot for the life of me find the values that were
    > entered into the text boxes. When I turn tracing on, I see in the 'Form
    > Collection' that my values have in fact been kept via ViewState, but when
    > I
    > go into the Table object, the 'rows' are empty.
    >
    > I'm sure this is going to be a difficult one to diagnose via this post as
    > it
    > appears to be pretty vague, bug perhaps if you can explain to me how to
    > find
    > a control by either the control ID or by the Unique ID? The Unique ID is
    > shown in the trace output. I've tried using a debugger and examined the
    > Table object in a watch window, but there are a million nodes on that.
    >
    > Please help!! This has been keeping me up at night. It seems like such a
    > simple friggin thing.
    >
    > --
    > Jaan
     
    Ken Cox [Microsoft MVP], Sep 20, 2006
    #3
  4. I'll post the source code tonight, or email it, as I currently don't have
    access to it.

    However, I am using a master page, and on that master page I have a content
    placeholder, and in the implementation page that uses that master page, I
    have in that placeholder:
    <asp:Table runat="server" ID="QuestionTable" />

    Then in my code behind page I populate that table with rows, each row
    consisting of two cells. The first cell just has some text, the next cell has
    a textbox.
    This is done at runtime because the user can make choices which will
    determine how many rows are put into that table.

    In the Page_Init/ or Page_load or whatever it was (I don't remember the
    function name exactly, but its the one method that VS puts in there for you)
    The first time the page loads, I populate the table, and I can access the
    first row->second cell with this:
    ((TextBox)this.QuestionTable.Rows[0].Cells[1].Controls[0]).Text; I can set
    the text and I can read it. But when I put the same thing after checking for
    IsPostBack, it doesn't have the posted back values!!!
    I've looked at all kinds of data in the debugger, I've looked at the trace
    output, I just cant find this data!

    Thanks for getting back to me so soon.

    Jaan

    --
    Jaan


    "Ken Cox [Microsoft MVP]" wrote:

    > Hi Jann,
    >
    > What kind of table are you using? A plain HTML table? A datagrid? An ASP.NET
    > table?
    >
    > It would help to see the code that isn't working.
    >
    > Ken
    > Microsoft MVP [ASP.NET]
    >
    > "jrett" <> wrote in message
    > news:...
    > > I'm new to ASP.NET and fairly inexperienced with web development in
    > > general,
    > > but I've been a professional software dev for over 10 years, C++, Unix and
    > > windows, C# the past 4 years.
    > >
    > > I've been working on a personal ASP.NET project, basically as a learning
    > > tool and I have a major issue which is really really getting on my nerves.
    > >
    > > I'm creating a web application in ASP.NET 2.0 which dynamically populates
    > > a
    > > table with text and text boxes. This table has two columns; in the left
    > > colum
    > > are fields labelling the text boxes on the right column.
    > >
    > > After post back, I cannot for the life of me find the values that were
    > > entered into the text boxes. When I turn tracing on, I see in the 'Form
    > > Collection' that my values have in fact been kept via ViewState, but when
    > > I
    > > go into the Table object, the 'rows' are empty.
    > >
    > > I'm sure this is going to be a difficult one to diagnose via this post as
    > > it
    > > appears to be pretty vague, bug perhaps if you can explain to me how to
    > > find
    > > a control by either the control ID or by the Unique ID? The Unique ID is
    > > shown in the trace output. I've tried using a debugger and examined the
    > > Table object in a watch window, but there are a million nodes on that.
    > >
    > > Please help!! This has been keeping me up at night. It seems like such a
    > > simple friggin thing.
    > >
    > > --
    > > Jaan

    >
    >
    >
     
    =?Utf-8?B?anJldHQ=?=, Sep 21, 2006
    #4
  5. Okay, apparently there is not way to post my sources, so I'll try to copy and
    paste the relevant portions.


    protected void Page_Load(object sender, EventArgs e)
    {
    if (this.IsPostBack)
    {
    // if we don't re-render the table and it's text boxes, the
    viewstate for these controls is lost.
    TableRow[] tableRows =
    WebMadLibEngine.GetMadLibTableData((string)this.ViewState["FilePathName"]);
    this.QuestionTable.Rows.AddRange(tableRows);

    //Server.Transfer("MadLibDisplayPage.aspx");

    Response.Write(string.Format("The first text box says: [{0}]",

    ((TextBox)this.QuestionTable.Rows[0].Cells[1].Controls[0]).Text));

    ((TextBox)this.QuestionTable.Rows[2].Cells[1].Controls[0]).Text
    = "Setting this also the hard way.";
    }
    else if (this.PreviousPage != null)
    {
    this.MadLibTitle.Text =
    Path.GetFileNameWithoutExtension(PreviousPage.SelectedMadLibFilePathName);
    this.ViewState.Add("FilePathName",
    PreviousPage.SelectedMadLibFilePathName);

    TableRow[] tableRows =
    WebMadLibEngine.GetMadLibTableData(PreviousPage.SelectedMadLibFilePathName);

    this.QuestionTable.Rows.AddRange(tableRows);

    ((TextBox)this.QuestionTable.Rows[1].Cells[1].Controls[0]).Text
    = "Setting this the hard way.";
    }
    else
    {
    // if there is no previous page, then let's load it!!
    Server.Transfer("MadLibSelectionPage.aspx");
    }
    }




    --
    Jaan


    "jrett" wrote:

    > I'll post the source code tonight, or email it, as I currently don't have
    > access to it.
    >
    > However, I am using a master page, and on that master page I have a content
    > placeholder, and in the implementation page that uses that master page, I
    > have in that placeholder:
    > <asp:Table runat="server" ID="QuestionTable" />
    >
    > Then in my code behind page I populate that table with rows, each row
    > consisting of two cells. The first cell just has some text, the next cell has
    > a textbox.
    > This is done at runtime because the user can make choices which will
    > determine how many rows are put into that table.
    >
    > In the Page_Init/ or Page_load or whatever it was (I don't remember the
    > function name exactly, but its the one method that VS puts in there for you)
    > The first time the page loads, I populate the table, and I can access the
    > first row->second cell with this:
    > ((TextBox)this.QuestionTable.Rows[0].Cells[1].Controls[0]).Text; I can set
    > the text and I can read it. But when I put the same thing after checking for
    > IsPostBack, it doesn't have the posted back values!!!
    > I've looked at all kinds of data in the debugger, I've looked at the trace
    > output, I just cant find this data!
    >
    > Thanks for getting back to me so soon.
    >
    > Jaan
    >
    > --
    > Jaan
    >
    >
    > "Ken Cox [Microsoft MVP]" wrote:
    >
    > > Hi Jann,
    > >
    > > What kind of table are you using? A plain HTML table? A datagrid? An ASP.NET
    > > table?
    > >
    > > It would help to see the code that isn't working.
    > >
    > > Ken
    > > Microsoft MVP [ASP.NET]
    > >
    > > "jrett" <> wrote in message
    > > news:...
    > > > I'm new to ASP.NET and fairly inexperienced with web development in
    > > > general,
    > > > but I've been a professional software dev for over 10 years, C++, Unix and
    > > > windows, C# the past 4 years.
    > > >
    > > > I've been working on a personal ASP.NET project, basically as a learning
    > > > tool and I have a major issue which is really really getting on my nerves.
    > > >
    > > > I'm creating a web application in ASP.NET 2.0 which dynamically populates
    > > > a
    > > > table with text and text boxes. This table has two columns; in the left
    > > > colum
    > > > are fields labelling the text boxes on the right column.
    > > >
    > > > After post back, I cannot for the life of me find the values that were
    > > > entered into the text boxes. When I turn tracing on, I see in the 'Form
    > > > Collection' that my values have in fact been kept via ViewState, but when
    > > > I
    > > > go into the Table object, the 'rows' are empty.
    > > >
    > > > I'm sure this is going to be a difficult one to diagnose via this post as
    > > > it
    > > > appears to be pretty vague, bug perhaps if you can explain to me how to
    > > > find
    > > > a control by either the control ID or by the Unique ID? The Unique ID is
    > > > shown in the trace output. I've tried using a debugger and examined the
    > > > Table object in a watch window, but there are a million nodes on that.
    > > >
    > > > Please help!! This has been keeping me up at night. It seems like such a
    > > > simple friggin thing.
    > > >
    > > > --
    > > > Jaan

    > >
    > >
    > >
     
    =?Utf-8?B?anJldHQ=?=, Sep 22, 2006
    #5
    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. Don Bruder
    Replies:
    11
    Views:
    613
    Kevin Goodsell
    Sep 21, 2003
  2. Steve D. Perkins

    Rookie question about data types (hashtables)

    Steve D. Perkins, Jan 29, 2004, in forum: Python
    Replies:
    7
    Views:
    388
    Rainer Deyke
    Jan 29, 2004
  3. jrett
    Replies:
    2
    Views:
    119
    Bob Barrows [MVP]
    Sep 20, 2006
  4. ...D.
    Replies:
    2
    Views:
    120
    Randy Webb
    Sep 18, 2004
  5. GRLCOPM

    Help needed for perl rookie

    GRLCOPM, Dec 27, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    173
    GRLCOPM
    Dec 28, 2004
Loading...

Share This Page