Form Submission to another url from DNN module – cross site posting-POST/form in Asp.net


Hi All,
I’m posting this today I’m very sure that somebody will definitely help this.Coz I wasted some valuable time of mine for finding good solution for this.
Yes In Asp.Net you can’t nested forms.If you r using DNN the difficulty of using that is much more.So I was one of those L

Ok its like this.

You can create the form in code behind and send it via javascript.form action will set by javascript.

 StringBuilder htmlForm = new StringBuilder();
String paymentUrl=”Url of posting”;
            htmlForm.AppendLine(String.Format("<input type='hidden' name='itemQuantity1' value='1'>"));
            htmlForm.AppendLine(String.Format("<input type='hidden' name='itemPrice1' value='25000'>"));
            htmlForm.AppendLine(String.Format("<input type='hidden' name='validUntil' value='2012-01-28T12:00:00:000Z'>"));
            htmlForm.AppendLine("<input value=" + '"' + "Let's Pay Now" + '"' + "onclick=" + '"' + "this.form.method='post';this.form.content='text/html'; this.form.action='" + paymentUrl + "';this.form.submit();" + '"' + " type='submit' />");
            htmlCode.Text = htmlForm.ToString();


Ahh..remember to add that string of form in to asp Literal.

Try this guys! Leave a comment if you are happy!

10 comments: