basic form question - two forms one page. ??

Discussion in 'ASP .Net' started by Aussie Rules, Aug 11, 2007.

  1. Aussie Rules

    Aussie Rules Guest

    Hi,

    I have an asp.net 2.0 page that has two sections. Each section allows the
    user to enter a value into a text box, click a button and then perform some
    function. Each text boxes function is different to the other and takes the
    user to a different part of the web site after doing some SQL work

    I have placed a form tag around each of the text boxes section. Each has a
    different 'form id', however when i try to execute the web site, it says 'A
    page can have only one server-side form tag.

    How do i cope with my situation ?

    Thanks
     
    Aussie Rules, Aug 11, 2007
    #1
    1. Advertising

  2. "Aussie Rules" <> wrote in message
    news:...

    > How do i cope with my situation ?


    Use one form.

    Each button has its own server-side events, so just take appropriate action
    as required.

    E.g.

    Button1 does its processing and then does a Response.Redirect to page2.aspx
    (or whatever)

    Button2 does its processing and then does a Response.Redirect to page7.aspx
    (or whatever)


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Aug 11, 2007
    #2
    1. Advertising

  3. Aussie Rules

    Teemu Keiski Guest

    You can have multiple forms but only one can be server-side e.g with
    runat="server". You can use cross-page postbacks in ASP.NET 2.0 to post on
    different pages per button basis (set PostBackUrl="targetpage.aspx" on the
    Button) while having single form on the Page. Assuming that you initiate
    some task based on Button click...

    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net

    "Aussie Rules" <> wrote in message
    news:...
    > Hi,
    >
    > I have an asp.net 2.0 page that has two sections. Each section allows the
    > user to enter a value into a text box, click a button and then perform
    > some function. Each text boxes function is different to the other and
    > takes the user to a different part of the web site after doing some SQL
    > work
    >
    > I have placed a form tag around each of the text boxes section. Each has a
    > different 'form id', however when i try to execute the web site, it says
    > 'A page can have only one server-side form tag.
    >
    > How do i cope with my situation ?
    >
    > Thanks
     
    Teemu Keiski, Aug 12, 2007
    #3
  4. Hi Aussie,

    The ASP.NET web page is a customized html based web page, one particularity
    is that ASP.NET web page use a <form> with "runat=server" attribute, this
    is used as the container of any other ASP.NET server controls, and all
    those server controls' postback event can be correctly detected if they're
    put inside this server-side form tag. Also, there can only contains single
    "runat=server" <form> tag in an ASP.NET web page.

    For your scenario, if you want to post different data field entries through
    different button on the same page, I think you can consider the following
    two means:

    1. If you're using ASP.NET 2.0, you can utilize the "cross-page post"
    feature, this can let you define multiple buttons on a single page and
    configure them to postbac k to different url:

    #How to: Post ASP.NET Web Pages to a Different Page
    http://msdn2.microsoft.com/en-us/library/ms178140.aspx

    #Cross-Page Posting in ASP.NET Web Pages
    http://msdn2.microsoft.com/en-us/library/ms178139.aspx


    2. You can certainly put multiple html <form> tags in a single ASP.NET web
    page. However, make sure that only one form has the "runat" attribute set
    as "true". Also, for ASP.NET server controls, they can only be put in
    "runat=server" <form> e.g.


    =======in aspx page========

    <body>
    ...
    <form id="form1" runat="server">
    you can put ASP.NET server controls here
    .........
    </form>

    <form id="form2" action="other page'>
    you can put only pure html elements here
    ........
    </form>

    <form id="form2" action="other page'>
    you can put only pure html elements here
    ........
    </form>
    ........
    =============

    If you have any more specific questions on this, please feel free to post
    here.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Aug 13, 2007
    #4
  5. Hi Aussie,

    Have you got any further idea on this issue or does the suggestion in
    previous replies help you some? If there is anything else we can help,
    please feel free to post here.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Aug 15, 2007
    #5
  6. Aussie Rules

    Aussie Rules Guest

    Hi,

    thanks this is now sorted with you input..

    thanks
    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Aussie,
    >
    > Have you got any further idea on this issue or does the suggestion in
    > previous replies help you some? If there is anything else we can help,
    > please feel free to post here.
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
     
    Aussie Rules, Aug 15, 2007
    #6
  7. Glad to be of assistance!

    Have a good day!

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead
     
    Steven Cheng[MSFT], Aug 15, 2007
    #7
    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. Walter W
    Replies:
    0
    Views:
    508
    Walter W
    Jul 22, 2005
  2. Andrew

    two post forms on one page?

    Andrew, Feb 5, 2004, in forum: HTML
    Replies:
    1
    Views:
    5,576
    Weyoun the Dancing Borg
    Feb 5, 2004
  3. news.frontiernet.net
    Replies:
    6
    Views:
    1,153
    news.frontiernet.net
    Apr 16, 2004
  4. Rob R. Ainscough
    Replies:
    3
    Views:
    355
    Rob R. Ainscough
    Jun 14, 2005
  5. Tyrone Slothrop

    One Form, Two Targets, Two Actions

    Tyrone Slothrop, Dec 28, 2006, in forum: Javascript
    Replies:
    5
    Views:
    169
    Jonas Raoni
    Dec 29, 2006
Loading...

Share This Page