How do I get a form to post to another page when runat="server" is true?

Discussion in 'ASP .Net' started by COHENMARVIN, Jul 28, 2005.

  1. COHENMARVIN

    COHENMARVIN Guest

    I'm a asp programmer starting out with asp.net. I understand that an
    asp form can post to its own page and that this allows validation of
    form fields on the server. But suppose all the controls turn out to be
    valid, and now I want to move to a new page?
    My form declaration looks like this:
    <form METHOD="POST" ACTION="sites2.aspx" name="MyForm" runat="server">
    This form declaration is on a page called sites1.aspx, but it doesn't
    post any data to sites2.aspx. In fact, "sites2.aspx" doesn't show up
    at all, instead I keep getting sites1.aspx every time I click on the
    SUBMIT button.
    What am I doing wrong?
    Thanks,
    CohenMarvin
     
    COHENMARVIN, Jul 28, 2005
    #1
    1. Advertising

  2. COHENMARVIN

    Marina Guest

    But if the validation is happening on the server, that means the page has
    already posted back to itself. So the Action was pointing to the current
    page.

    I dont' really understand what you are trying to do here.

    I would recommend you throw out 95% of the techniques you used to get things
    done in ASP. They will typically only lead you down the wrong path.

    Your page should validate its own data, and process it. Once it is done, it
    should redirect to the next logical page in your application. This page
    should follow the same model. Every page is typically self contained - it
    does not need the help of any other page to do its processing.

    Hope that helps.

    "COHENMARVIN" <> wrote in message
    news:...
    > I'm a asp programmer starting out with asp.net. I understand that an
    > asp form can post to its own page and that this allows validation of
    > form fields on the server. But suppose all the controls turn out to be
    > valid, and now I want to move to a new page?
    > My form declaration looks like this:
    > <form METHOD="POST" ACTION="sites2.aspx" name="MyForm" runat="server">
    > This form declaration is on a page called sites1.aspx, but it doesn't
    > post any data to sites2.aspx. In fact, "sites2.aspx" doesn't show up
    > at all, instead I keep getting sites1.aspx every time I click on the
    > SUBMIT button.
    > What am I doing wrong?
    > Thanks,
    > CohenMarvin
    >
     
    Marina, Jul 28, 2005
    #2
    1. Advertising

  3. Re: How do I get a form to post to another page when runat="server

    SO true... in the page_load event you should use the If logic as follows

    If Not IsPostback then
    load page for the first time
    else
    validate process
    SERVER.TRANSFER("page2.aspx")
    end if



    "Marina" wrote:

    > But if the validation is happening on the server, that means the page has
    > already posted back to itself. So the Action was pointing to the current
    > page.
    >
    > I dont' really understand what you are trying to do here.
    >
    > I would recommend you throw out 95% of the techniques you used to get things
    > done in ASP. They will typically only lead you down the wrong path.
    >
    > Your page should validate its own data, and process it. Once it is done, it
    > should redirect to the next logical page in your application. This page
    > should follow the same model. Every page is typically self contained - it
    > does not need the help of any other page to do its processing.
    >
    > Hope that helps.
    >
    > "COHENMARVIN" <> wrote in message
    > news:...
    > > I'm a asp programmer starting out with asp.net. I understand that an
    > > asp form can post to its own page and that this allows validation of
    > > form fields on the server. But suppose all the controls turn out to be
    > > valid, and now I want to move to a new page?
    > > My form declaration looks like this:
    > > <form METHOD="POST" ACTION="sites2.aspx" name="MyForm" runat="server">
    > > This form declaration is on a page called sites1.aspx, but it doesn't
    > > post any data to sites2.aspx. In fact, "sites2.aspx" doesn't show up
    > > at all, instead I keep getting sites1.aspx every time I click on the
    > > SUBMIT button.
    > > What am I doing wrong?
    > > Thanks,
    > > CohenMarvin
    > >

    >
    >
    >
     
    =?Utf-8?B?QnJpYW4gRg==?=, Jul 28, 2005
    #3
  4. COHENMARVIN

    Marina Guest

    Re: How do I get a form to post to another page when runat="server

    Or more typically, there is some sort of button click handler, or something
    like that. So depending on what button go clicked or what not, the
    processing may be a bit different.

    But that's the general idea.

    "Brian F" <> wrote in message
    news:...
    > SO true... in the page_load event you should use the If logic as follows
    >
    > If Not IsPostback then
    > load page for the first time
    > else
    > validate process
    > SERVER.TRANSFER("page2.aspx")
    > end if
    >
    >
    >
    > "Marina" wrote:
    >
    >> But if the validation is happening on the server, that means the page has
    >> already posted back to itself. So the Action was pointing to the current
    >> page.
    >>
    >> I dont' really understand what you are trying to do here.
    >>
    >> I would recommend you throw out 95% of the techniques you used to get
    >> things
    >> done in ASP. They will typically only lead you down the wrong path.
    >>
    >> Your page should validate its own data, and process it. Once it is done,
    >> it
    >> should redirect to the next logical page in your application. This page
    >> should follow the same model. Every page is typically self contained -
    >> it
    >> does not need the help of any other page to do its processing.
    >>
    >> Hope that helps.
    >>
    >> "COHENMARVIN" <> wrote in message
    >> news:...
    >> > I'm a asp programmer starting out with asp.net. I understand that an
    >> > asp form can post to its own page and that this allows validation of
    >> > form fields on the server. But suppose all the controls turn out to be
    >> > valid, and now I want to move to a new page?
    >> > My form declaration looks like this:
    >> > <form METHOD="POST" ACTION="sites2.aspx" name="MyForm" runat="server">
    >> > This form declaration is on a page called sites1.aspx, but it doesn't
    >> > post any data to sites2.aspx. In fact, "sites2.aspx" doesn't show up
    >> > at all, instead I keep getting sites1.aspx every time I click on the
    >> > SUBMIT button.
    >> > What am I doing wrong?
    >> > Thanks,
    >> > CohenMarvin
    >> >

    >>
    >>
    >>
     
    Marina, Jul 28, 2005
    #4
  5. COHENMARVIN

    Scott Allen Guest

    There is no inherent support for cross page postbacks until v2.0 of
    ASP.NET. See:

    Design Considerations for Cross Page Post Backs in ASP.NET 2.0
    http://odetocode.com/Articles/421.aspx

    You can still use a couple techniques in the article to get to the
    other page, including Response.Redirect and Server.Transfer.

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/

    On 28 Jul 2005 08:00:01 -0700, "COHENMARVIN" <>
    wrote:

    >I'm a asp programmer starting out with asp.net. I understand that an
    >asp form can post to its own page and that this allows validation of
    >form fields on the server. But suppose all the controls turn out to be
    >valid, and now I want to move to a new page?
    >My form declaration looks like this:
    ><form METHOD="POST" ACTION="sites2.aspx" name="MyForm" runat="server">
    >This form declaration is on a page called sites1.aspx, but it doesn't
    >post any data to sites2.aspx. In fact, "sites2.aspx" doesn't show up
    >at all, instead I keep getting sites1.aspx every time I click on the
    >SUBMIT button.
    >What am I doing wrong?
    >Thanks,
    >CohenMarvin
     
    Scott Allen, Jul 28, 2005
    #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. Matthew Louden
    Replies:
    4
    Views:
    13,081
    Teemu Keiski
    Nov 18, 2003
  2. feng
    Replies:
    1
    Views:
    3,184
    Peter Rilling
    Feb 29, 2004
  3. =?Utf-8?B?d3J5dGF0?=

    form in a form that runat server?

    =?Utf-8?B?d3J5dGF0?=, Jun 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    433
    Steve C. Orr [MVP, MCSD]
    Jun 7, 2005
  4. André
    Replies:
    2
    Views:
    744
    André
    Jun 23, 2008
  5. bdb112
    Replies:
    45
    Views:
    1,354
    jazbees
    Apr 29, 2009
Loading...

Share This Page