Reputation: 302
How do you change the form action in WebForms to post to a different page, not to a page in your application. Is it possible to use 'response.redirect' to post to a third party page?
Since the form tag exist in the master page, it will always postback to itself. Normally, I would use response.redirect to post to another page within my application, but I don't know about to a third party page. I've tried to give the form an ID and then change it on the page when it loads,
form1.Action = "myURL";
But it doesn't recognized the ID because it only exist in the master page.
Upvotes: 0
Views: 3217
Reputation: 920
If you want to change the form action of the masterpage to post to a third party page you need to find the control on the content page and then update the property as above. Use this in your page load for the content page:
protected void Page_Load(object sender, EventArgs e)
{
var form = (HtmlForm)this.Master.FindControl("form1");
form.Action = "http://blarg.com";
}
Upvotes: 1