C# how to retrieve post data

asp.netc

If I have a textbox txtInfo in a form that I submit via post, if I post back to the page I can read the value entered in the textbox using txtInfo.Text. What if I am posting to a different page? Do I have to parse Request.Form for the control name mutilations (which is what I am doing now) or can I get it from that mess .net passes around as state?

Thanks


Thank you for the answers so far… Sorry I should have been a little more clear. This control is a runat="server" control. This is what I am relegated to now – not very pretty.

    foreach (String key in page.Request.Form.AllKeys)
    {
        String[] controlName = key.Split('$');//remove that horrrible .net naming - thanks Bill.
        keyName = controlName[controlName.Length - 1];//get the last value so we always have the name
        keyValue = page.Request.Form[key];
        if (keyValue != "")
        {
            switch (keyName)...

Best Answer

You should look into Cross Page Postbacks.

As noted on this page you can easily get access to txtInfo using the following:

if (Page.PreviousPage != null)
{
    TextBox SourceTextBox = 
        (TextBox)Page.PreviousPage.FindControl("txtInfo");
    if (SourceTextBox != null)
    {
        Label1.Text = SourceTextBox.Text;
    }
}