Powered by Blogger.

Sunday, February 16, 2014

Post form data to 3rd party URL in Asp.Net




In this post we will discuss how we can send form data to a 3rd party URL in Asp.Net.

Also you can check my previous posts on asp.net mvc 4 tutorial, Generics tutorial in C#.Net and Tutorial on Cookies in asp.net.

There will be certain situations where you will not prefer to send data through query string to a 3rd party URL. In that we can use the post method to send data to the 3rd party URL.

For this we have to write a JavaScript method as well as we need to put input variables inside the form tag. Follow the below code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Post form data to 3rd party URL in Asp.Net</title>
    <script language="javascript" type="text/javascript">
        function postvaluesTraining() {
            document.forms[0].action = 'http://UR 3rd Party URL/welcome.aspx';
            document.forms[0].submit();
            return true;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
<input type="hidden" name="Name" value="aspdotnethelp" />
<input type="hidden" name="siteURL" value="www.aspdotnethelp.com" />
<input type="hidden" name="email" value="aspdotnethelp24@gmail.com" />
 </div>
    </div>
</form>
</body>
</html>



0 comments

Post a Comment