Asp.net form submit action question

Discussion in 'ASP .Net' started by TheOne, Feb 15, 2005.

  1. TheOne

    TheOne Guest

    In Asp.net web form under form tag there is action field that I am point to
    some other page, and not to same web form. When I run this page it is always
    pointing to itself. How do I get around this?

    Here is HTML code from webform..

    Thanks,

    Sinisa

    <%@ Page Language="vb" AutoEventWireup="false"
    Codebehind="BusinessTest.aspx.vb" Inherits="EDMSearchForms.BusinessTest"
    EnableSessionState="True" enableViewState="True"%>
    <%@ Register TagPrefix="uc1" TagName="BusinessDirectoryUC"
    Src="../Forms/BusinessDirectoryUC.ascx" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>BusinessTest</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema"
    content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="search1" method="post" runat="server"
    action="http://www.techtriangle.com/search/SearchResultsWaterloo.cfm"
    name="search">
    <input type="hidden" name="SearchScope" value="Business">
    </form>
    </body>
    </HTML>
     
    TheOne, Feb 15, 2005
    #1
    1. Advertising

  2. using the <form runat="server"> you *cannot" have a value for action. All
    aspx forms must post back to the same page. If you remove the runat="server"
    you may be able to do this; but you have stick to html controls

    "TheOne" wrote:

    > In Asp.net web form under form tag there is action field that I am point to
    > some other page, and not to same web form. When I run this page it is always
    > pointing to itself. How do I get around this?
    >
    > Here is HTML code from webform..
    >
    > Thanks,
    >
    > Sinisa
    >
    > <%@ Page Language="vb" AutoEventWireup="false"
    > Codebehind="BusinessTest.aspx.vb" Inherits="EDMSearchForms.BusinessTest"
    > EnableSessionState="True" enableViewState="True"%>
    > <%@ Register TagPrefix="uc1" TagName="BusinessDirectoryUC"
    > Src="../Forms/BusinessDirectoryUC.ascx" %>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <HTML>
    > <HEAD>
    > <title>BusinessTest</title>
    > <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    > <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    > <meta name="vs_defaultClientScript" content="JavaScript">
    > <meta name="vs_targetSchema"
    > content="http://schemas.microsoft.com/intellisense/ie5">
    > </HEAD>
    > <body MS_POSITIONING="GridLayout">
    > <form id="search1" method="post" runat="server"
    > action="http://www.techtriangle.com/search/SearchResultsWaterloo.cfm"
    > name="search">
    > <input type="hidden" name="SearchScope" value="Business">
    > </form>
    > </body>
    > </HTML>
    >
    >
    >
     
    =?Utf-8?B?VGFtcGEgLk5FVCBLb2Rlcg==?=, Feb 15, 2005
    #2
    1. Advertising

  3. You've got to ger rid of the runat=server for the form. An ASP.Net form must
    post back to itself to handle certain kinds of events, like catching a
    button's click by the server.

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - FrontPage

    "TheOne" <> wrote in message
    news:...
    > In Asp.net web form under form tag there is action field that I am point
    > to
    > some other page, and not to same web form. When I run this page it is
    > always
    > pointing to itself. How do I get around this?
    >
    > Here is HTML code from webform..
    >
    > Thanks,
    >
    > Sinisa
    >
    > <%@ Page Language="vb" AutoEventWireup="false"
    > Codebehind="BusinessTest.aspx.vb" Inherits="EDMSearchForms.BusinessTest"
    > EnableSessionState="True" enableViewState="True"%>
    > <%@ Register TagPrefix="uc1" TagName="BusinessDirectoryUC"
    > Src="../Forms/BusinessDirectoryUC.ascx" %>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <HTML>
    > <HEAD>
    > <title>BusinessTest</title>
    > <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    > <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    > <meta name="vs_defaultClientScript" content="JavaScript">
    > <meta name="vs_targetSchema"
    > content="http://schemas.microsoft.com/intellisense/ie5">
    > </HEAD>
    > <body MS_POSITIONING="GridLayout">
    > <form id="search1" method="post" runat="server"
    > action="http://www.techtriangle.com/search/SearchResultsWaterloo.cfm"
    > name="search">
    > <input type="hidden" name="SearchScope" value="Business">
    > </form>
    > </body>
    > </HTML>
    >
    >
     
    Mark Fitzpatrick, Feb 15, 2005
    #3
  4. TheOne

    TheOne Guest

    I have to use server controls since I will be putting in user control for
    it. Is it possible to use response.redirect to submit form? Is there some
    other solution. Somehow I need to post information from this form.

    Thanks,

    Sinisa

    "TheOne" <> wrote in message
    news:...
    > In Asp.net web form under form tag there is action field that I am point

    to
    > some other page, and not to same web form. When I run this page it is

    always
    > pointing to itself. How do I get around this?
    >
    > Here is HTML code from webform..
    >
    > Thanks,
    >
    > Sinisa
    >
    > <%@ Page Language="vb" AutoEventWireup="false"
    > Codebehind="BusinessTest.aspx.vb" Inherits="EDMSearchForms.BusinessTest"
    > EnableSessionState="True" enableViewState="True"%>
    > <%@ Register TagPrefix="uc1" TagName="BusinessDirectoryUC"
    > Src="../Forms/BusinessDirectoryUC.ascx" %>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <HTML>
    > <HEAD>
    > <title>BusinessTest</title>
    > <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    > <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    > <meta name="vs_defaultClientScript" content="JavaScript">
    > <meta name="vs_targetSchema"
    > content="http://schemas.microsoft.com/intellisense/ie5">
    > </HEAD>
    > <body MS_POSITIONING="GridLayout">
    > <form id="search1" method="post" runat="server"
    > action="http://www.techtriangle.com/search/SearchResultsWaterloo.cfm"
    > name="search">
    > <input type="hidden" name="SearchScope" value="Business">
    > </form>
    > </body>
    > </HTML>
    >
    >
     
    TheOne, Feb 15, 2005
    #4
  5. AP.NET 2.0 solves this issue. However, its only in BETA. So, you can't
    have the best of both worlds. Either you stick with the current model by
    having the form post back to itself or do as we suggested. If that doesn't
    work for you. Then maybe asp.net is not the right solution for you. Give
    classic ASP a try. :)

    "TheOne" wrote:

    > I have to use server controls since I will be putting in user control for
    > it. Is it possible to use response.redirect to submit form? Is there some
    > other solution. Somehow I need to post information from this form.
    >
    > Thanks,
    >
    > Sinisa
    >
    > "TheOne" <> wrote in message
    > news:...
    > > In Asp.net web form under form tag there is action field that I am point

    > to
    > > some other page, and not to same web form. When I run this page it is

    > always
    > > pointing to itself. How do I get around this?
    > >
    > > Here is HTML code from webform..
    > >
    > > Thanks,
    > >
    > > Sinisa
    > >
    > > <%@ Page Language="vb" AutoEventWireup="false"
    > > Codebehind="BusinessTest.aspx.vb" Inherits="EDMSearchForms.BusinessTest"
    > > EnableSessionState="True" enableViewState="True"%>
    > > <%@ Register TagPrefix="uc1" TagName="BusinessDirectoryUC"
    > > Src="../Forms/BusinessDirectoryUC.ascx" %>
    > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > > <HTML>
    > > <HEAD>
    > > <title>BusinessTest</title>
    > > <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    > > <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    > > <meta name="vs_defaultClientScript" content="JavaScript">
    > > <meta name="vs_targetSchema"
    > > content="http://schemas.microsoft.com/intellisense/ie5">
    > > </HEAD>
    > > <body MS_POSITIONING="GridLayout">
    > > <form id="search1" method="post" runat="server"
    > > action="http://www.techtriangle.com/search/SearchResultsWaterloo.cfm"
    > > name="search">
    > > <input type="hidden" name="SearchScope" value="Business">
    > > </form>
    > > </body>
    > > </HTML>
    > >
    > >

    >
    >
    >
     
    =?Utf-8?B?VGFtcGEgLk5FVCBLb2Rlcg==?=, Feb 15, 2005
    #5
  6. TheOne

    steve-o Guest

    "TheOne" <> wrote in message
    news:...
    > In Asp.net web form under form tag there is action field that I am point

    to
    > some other page, and not to same web form. When I run this page it is

    always
    > pointing to itself. How do I get around this?
    >
    > Here is HTML code from webform..
    >
    > Thanks,
    >
    > Sinisa


    To transfer to another webpage look into one of these three options:
    Response.Redirect
    Server.Transfer
    Server.Execute

    Managing ASP.NET Navigation
    http://www.ondotnet.com/pub/a/dotnet/2003/04/07/aspnetnav.html

    Hope this helps,
    Steve-O
     
    steve-o, Feb 15, 2005
    #6
  7. I'm trying to do something similar, to do a POST to paypal. In my quick
    testing, I don't see that removing runat=server and using server controls are
    mutually exclusive, it's just that you can't process any events from those
    controls (which you don't care about, because you're off to another page
    anyway).

    In my test, I have a single placeholder on the form, and the <form> has
    "runat=server" gone, method="post" and action="paypal, etc.". In the
    code-behind I add htmlinputhidden fields to the placeholder for all my
    name/value pairs (appears that I have to set id= for each, which sets both
    name= and id=, not sure why).

    When I submit this form it goes to paypal with the post values as planned.
    Last piece I'm working on is to do the submit automatically, which per
    various posts out here I think I can do as document.forms[0].submit().

    hth,

    Bill

    "TheOne" wrote:

    > In Asp.net web form under form tag there is action field that I am point to
    > some other page, and not to same web form. When I run this page it is always
    > pointing to itself. How do I get around this?
    >
    > Here is HTML code from webform..
    >
    > Thanks,
    >
    > Sinisa
    >
    > <%@ Page Language="vb" AutoEventWireup="false"
    > Codebehind="BusinessTest.aspx.vb" Inherits="EDMSearchForms.BusinessTest"
    > EnableSessionState="True" enableViewState="True"%>
    > <%@ Register TagPrefix="uc1" TagName="BusinessDirectoryUC"
    > Src="../Forms/BusinessDirectoryUC.ascx" %>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <HTML>
    > <HEAD>
    > <title>BusinessTest</title>
    > <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    > <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    > <meta name="vs_defaultClientScript" content="JavaScript">
    > <meta name="vs_targetSchema"
    > content="http://schemas.microsoft.com/intellisense/ie5">
    > </HEAD>
    > <body MS_POSITIONING="GridLayout">
    > <form id="search1" method="post" runat="server"
    > action="http://www.techtriangle.com/search/SearchResultsWaterloo.cfm"
    > name="search">
    > <input type="hidden" name="SearchScope" value="Business">
    > </form>
    > </body>
    > </HTML>
    >
    >
    >
     
    =?Utf-8?B?QmlsbCBCb3Jn?=, Feb 15, 2005
    #7
  8. What is the "proper" way to programmatically call another page in your app
    while passing it information? QueryString has length limitations, Session
    would seem to be an improper place for page-to-page, but Context.Items don't
    actually get saved to the page source, so there's no "history" with those.
    I'm curious what the right way is because I'm struggling with related
    issues, and right now, I'm dropping a webcontrol on my pages called
    ContextItemRetentionBlock that renders hidden inputs with those values to
    the page so that they don't get lost with the context.

    "Mark Fitzpatrick" <> wrote in message
    news:...
    > You've got to ger rid of the runat=server for the form. An ASP.Net form
    > must post back to itself to handle certain kinds of events, like catching
    > a button's click by the server.
    >
    > Hope this helps,
    > Mark Fitzpatrick
    > Microsoft MVP - FrontPage
    >
    > "TheOne" <> wrote in message
    > news:...
    >> In Asp.net web form under form tag there is action field that I am point
    >> to
    >> some other page, and not to same web form. When I run this page it is
    >> always
    >> pointing to itself. How do I get around this?
    >>
    >> Here is HTML code from webform..
    >>
    >> Thanks,
    >>
    >> Sinisa
    >>
    >> <%@ Page Language="vb" AutoEventWireup="false"
    >> Codebehind="BusinessTest.aspx.vb" Inherits="EDMSearchForms.BusinessTest"
    >> EnableSessionState="True" enableViewState="True"%>
    >> <%@ Register TagPrefix="uc1" TagName="BusinessDirectoryUC"
    >> Src="../Forms/BusinessDirectoryUC.ascx" %>
    >> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    >> <HTML>
    >> <HEAD>
    >> <title>BusinessTest</title>
    >> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    >> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    >> <meta name="vs_defaultClientScript" content="JavaScript">
    >> <meta name="vs_targetSchema"
    >> content="http://schemas.microsoft.com/intellisense/ie5">
    >> </HEAD>
    >> <body MS_POSITIONING="GridLayout">
    >> <form id="search1" method="post" runat="server"
    >> action="http://www.techtriangle.com/search/SearchResultsWaterloo.cfm"
    >> name="search">
    >> <input type="hidden" name="SearchScope" value="Business">
    >> </form>
    >> </body>
    >> </HTML>
    >>
    >>

    >
    >
     
    Keith Patrick, Feb 15, 2005
    #8
  9. P.S. Turns out it was cleaner to build the whole "redirect" page strictly via
    code in the helper class, e.g. "<html><body><form name= ...", etc., and
    output the hidden fields as literal text in the middle.

    "Bill Borg" wrote:

    > I'm trying to do something similar, to do a POST to paypal. In my quick
    > testing, I don't see that removing runat=server and using server controls are
    > mutually exclusive, it's just that you can't process any events from those
    > controls (which you don't care about, because you're off to another page
    > anyway).
    >
    > In my test, I have a single placeholder on the form, and the <form> has
    > "runat=server" gone, method="post" and action="paypal, etc.". In the
    > code-behind I add htmlinputhidden fields to the placeholder for all my
    > name/value pairs (appears that I have to set id= for each, which sets both
    > name= and id=, not sure why).
    >
    > When I submit this form it goes to paypal with the post values as planned.
    > Last piece I'm working on is to do the submit automatically, which per
    > various posts out here I think I can do as document.forms[0].submit().
    >
    > hth,
    >
    > Bill
    >
    > "TheOne" wrote:
    >
    > > In Asp.net web form under form tag there is action field that I am point to
    > > some other page, and not to same web form. When I run this page it is always
    > > pointing to itself. How do I get around this?
    > >
    > > Here is HTML code from webform..
    > >
    > > Thanks,
    > >
    > > Sinisa
    > >
    > > <%@ Page Language="vb" AutoEventWireup="false"
    > > Codebehind="BusinessTest.aspx.vb" Inherits="EDMSearchForms.BusinessTest"
    > > EnableSessionState="True" enableViewState="True"%>
    > > <%@ Register TagPrefix="uc1" TagName="BusinessDirectoryUC"
    > > Src="../Forms/BusinessDirectoryUC.ascx" %>
    > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > > <HTML>
    > > <HEAD>
    > > <title>BusinessTest</title>
    > > <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    > > <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    > > <meta name="vs_defaultClientScript" content="JavaScript">
    > > <meta name="vs_targetSchema"
    > > content="http://schemas.microsoft.com/intellisense/ie5">
    > > </HEAD>
    > > <body MS_POSITIONING="GridLayout">
    > > <form id="search1" method="post" runat="server"
    > > action="http://www.techtriangle.com/search/SearchResultsWaterloo.cfm"
    > > name="search">
    > > <input type="hidden" name="SearchScope" value="Business">
    > > </form>
    > > </body>
    > > </HTML>
    > >
    > >
    > >
     
    =?Utf-8?B?QmlsbCBCb3Jn?=, Feb 15, 2005
    #9
  10. P.S. Turns out it was cleaner to build the entire "redirect" page from
    scratch via code in the helper class, e.g. "<html><body><form name=...>",
    etc. and write the hidden fields as literal text in the middle.

    "Bill Borg" wrote:

    > I'm trying to do something similar, to do a POST to paypal. In my quick
    > testing, I don't see that removing runat=server and using server controls are
    > mutually exclusive, it's just that you can't process any events from those
    > controls (which you don't care about, because you're off to another page
    > anyway).
    >
    > In my test, I have a single placeholder on the form, and the <form> has
    > "runat=server" gone, method="post" and action="paypal, etc.". In the
    > code-behind I add htmlinputhidden fields to the placeholder for all my
    > name/value pairs (appears that I have to set id= for each, which sets both
    > name= and id=, not sure why).
    >
    > When I submit this form it goes to paypal with the post values as planned.
    > Last piece I'm working on is to do the submit automatically, which per
    > various posts out here I think I can do as document.forms[0].submit().
    >
    > hth,
    >
    > Bill
    >
    > "TheOne" wrote:
    >
    > > In Asp.net web form under form tag there is action field that I am point to
    > > some other page, and not to same web form. When I run this page it is always
    > > pointing to itself. How do I get around this?
    > >
    > > Here is HTML code from webform..
    > >
    > > Thanks,
    > >
    > > Sinisa
    > >
    > > <%@ Page Language="vb" AutoEventWireup="false"
    > > Codebehind="BusinessTest.aspx.vb" Inherits="EDMSearchForms.BusinessTest"
    > > EnableSessionState="True" enableViewState="True"%>
    > > <%@ Register TagPrefix="uc1" TagName="BusinessDirectoryUC"
    > > Src="../Forms/BusinessDirectoryUC.ascx" %>
    > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > > <HTML>
    > > <HEAD>
    > > <title>BusinessTest</title>
    > > <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    > > <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    > > <meta name="vs_defaultClientScript" content="JavaScript">
    > > <meta name="vs_targetSchema"
    > > content="http://schemas.microsoft.com/intellisense/ie5">
    > > </HEAD>
    > > <body MS_POSITIONING="GridLayout">
    > > <form id="search1" method="post" runat="server"
    > > action="http://www.techtriangle.com/search/SearchResultsWaterloo.cfm"
    > > name="search">
    > > <input type="hidden" name="SearchScope" value="Business">
    > > </form>
    > > </body>
    > > </HTML>
    > >
    > >
    > >
     
    =?Utf-8?B?QmlsbCBCb3Jn?=, Feb 15, 2005
    #10
  11. Hi Sinisa,

    Yes, currently the ASP.NET 1.x hasn't any buildin means for cross-page
    posting. If you do need to cross-post to different page, you can have a
    look at the following article which mentioned the scripting way:

    #Post an ASP.NET form with JavaScript
    http://www.codeproject.com/aspnet/jsnopostback.asp

    Also, the ASP.NET2.0 does provide complete and great support on cross-page
    posting. And provide more features on the cross-page interaction Model.

    Thanks.

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Feb 16, 2005
    #11
  12. TheOne

    TheOne Guest

    Hi, thanks this is what I am trying to do. Page that I am posting to is made
    in cold fusion. Our web designer gave me java script to use to change
    "action".

    Thanks,

    Sinisa

    code.....

    <script language="javascript" type="text/javascript">
    //<!--

    document.search1.action =
    'http://www.techtriangle.com/search/SearchResultsWaterloo.cfm';

    //-->
    </script>

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Sinisa,
    >
    > Yes, currently the ASP.NET 1.x hasn't any buildin means for cross-page
    > posting. If you do need to cross-post to different page, you can have a
    > look at the following article which mentioned the scripting way:
    >
    > #Post an ASP.NET form with JavaScript
    > http://www.codeproject.com/aspnet/jsnopostback.asp
    >
    > Also, the ASP.NET2.0 does provide complete and great support on cross-page
    > posting. And provide more features on the cross-page interaction Model.
    >
    > Thanks.
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
     
    TheOne, Feb 16, 2005
    #12
  13. Thanks for your followup.

    Glad that you've also found the tricks :)

    Good LUck!

    Thanks & Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Feb 17, 2005
    #13
    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. Jiho Han
    Replies:
    4
    Views:
    6,473
    Michael Ramey
    Feb 11, 2004
  2. Joe Bloggs
    Replies:
    1
    Views:
    797
    Sudsy
    Aug 3, 2003
  3. John
    Replies:
    0
    Views:
    884
  4. MZ
    Replies:
    1
    Views:
    236
    Erwin Moller
    May 23, 2007
  5. Replies:
    3
    Views:
    699
Loading...

Share This Page