Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7761189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:04:30+00:00 2026-06-01T14:04:30+00:00

I am having problem with overriding Form Action URL I have a class to

  • 0

I am having problem with overriding Form Action URL

I have a class to override the Form Action.

<html>
<head>
</head>
<body>
       <form id="form1" runat="Server"  action="https://www.test.com">
        <div style="">
            <asp:button runat="Server" onclick="PostMe" Text="Post"/>
        </div>

        <asp:HiddenField runat="server"  ID="test" value="0" />
        <asp:HiddenField runat="server"  ID="test2" value="0" />

    </form>
</body>
</html>





<script runat="server">

    void PostMe(Object sender,EventArgs e){

        RemotePost2 myremotepost =  new RemotePost2();
        myremotepost.Url = "https://www.test.com";
        myremotepost.Add("field1","Tom");
        myremotepost.Add("field2","Sawyer");
        myremotepost.Post();
    }


    public class RemotePost2{
            private System.Collections.Specialized.NameValueCollection Inputs = new System.Collections.Specialized.NameValueCollection();


            public string Url = "";
            public string Method = "post";
            public string FormName = "forms";

            public void Add(string name,string value){
                Inputs.Add(name,value);
            }

            public void Post(){
                System.Web.HttpContext.Current.Response.Clear();

                System.Web.HttpContext.Current.Response.Write("<html><head>");
                System.Web.HttpContext.Current.Response.Write(string.Format("</head><body onload=\"document.{0}.submit()\">",FormName));
                System.Web.HttpContext.Current.Response.Write(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >",FormName,Method,Url));
                for(int i=0;i< Inputs.Keys.Count;i++){
                    System.Web.HttpContext.Current.Response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">",Inputs.Keys[i],Inputs[Inputs.Keys[i]]));
                }
                System.Web.HttpContext.Current.Response.Write("</form>");
                System.Web.HttpContext.Current.Response.Write("</body></html>");

                System.Web.HttpContext.Current.Response.End();
            }
    }

The problem is I cannot post field1 and field2 instead the form posts test and test2 values. When I use postBackUrl attribute it still posts test and test2.

What I want to do is to post field1 and field2 when the form action is not blank. Because when there is no action it works fine and I cannot modify the action on the code.

Your help will be much appreciated
Cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:04:31+00:00Added an answer on June 1, 2026 at 2:04 pm

    You can add below to the code behind on load function

    myButton.Attributes.Add(“onClick”, “javascript:
    document.forms[0].action=’http://otherserver.com/theirpage.html’;”);

    where myButton will be id of your button.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem in relation to using super and overriding. Basically, class B
I'm having problem when running my Windows Forms program. In the program, I have
I am having problem that when i am trying to submit the form by
I'm having a little problem here! I have discovered the following as being the
After having written a few helper classes in magento, now i have this problem,
The problem I'm having is that when I'm using fields_for in a nested form,
Hey Folks am seemingly having problems with .htaccess files. The problem: I have a
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
I'm having problem with Rails plugin attachment_fu . On every upload, I get validation
i'm having problem to deal with charset in ruby on rails app, specificially in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.