Solved

another form in a asp.net page

Posted on 2013-12-19
7
339 Views
Last Modified: 2013-12-22
I need to have this form work on a asp.net page the area surrounded with "<% form action %>"  I have the asp form tag and I need this other one

any help?


<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/LandingPage.master" AutoEventWireup="true" CodeFile="CPADonateInsideOneColumnWithVideo.aspx.cs" Inherits="Templates_InsidePages_InsideOneColumnWithVideo" %>

<%@ Register Assembly="Ektron.Cms.Controls" Namespace="Ektron.Cms.Controls" TagPrefix="CMS" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
       
                         
                        <%
                            <form name="PrePage" method = "post" action = "https://Some otherserver.net/payment/CatalogPayment.aspx">
                            <input type = "hidden" name = "LinkId" value ="3e" />
                            <input type = "image" src ="//myserver.net/images/donate-gray.gif" />
                            </form>
                        %>
                        </div>
                    </div>
            </section>
</asp:Content>
0
Comment
Question by:bcrooks
  • 4
  • 3
7 Comments
 
LVL 21

Expert Comment

by:Dale Burrell
ID: 39730717
Its not possible.

You have 2 options that I know of:

1/ Put your second form outside the first form, but you can't do that when using masterpages.

2/ Use javascript to build a post a form when the submit button is clicked. Something like this:

	$('#calculate').click(function(){
	    $('body').append('<form action="http://some-other-server/etc.aspx" method="post" target="some-name" id="hidden_calc">'
			+'<input type="hidden" name="linkId" value="3e" />'
			+'<input type="submit" name="post form" value="post form" />'
			+'</form>');
			
		$('#hidden_calc').submit();
		$('#hidden_calc').remove();
		return false;
	});

Open in new window


There might be a third option, you may be able to do the postback from the server side - but that would be pretty complex.
0
 

Author Comment

by:bcrooks
ID: 39731914
if I do this - nothing shows
shouldn't  the img src be outside the click function?

<script type="text/javascript">
  $('#calculate').click(function(){
  $('body').append('<form action="https://Simple..net/payment/CatalogPayment.aspx" method="post" target="some-name" id="hidden_calc">'
+ '<input type="hidden" name="linkId" value="3e" />'
+ '<input type="image" src ="//content.net/images/donate-gray.gif" />'
+ '<input type="submit" name="post form" value="post form" />'
+ '</form>');
                  
                                $('#hidden_calc').submit();
                                $('#hidden_calc').remove();
                                return false;
                               });
                        </script>
0
 
LVL 21

Expert Comment

by:Dale Burrell
ID: 39733033
The way this script is written is specifically not to show anyway - all it shows is a regular ASP.NET button, which calls this in its onclick handler. It should all happen so fast that you would never see anything anyway.

You may want to put your image on the page using an ASP.NET image button, then wire the onclick handler into this code?

It depends what you want to be visible and when.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bcrooks
ID: 39733132
Sorry to be a pain, but we always want the button to show, then only activate upon click.

does that make sense?
0
 
LVL 21

Accepted Solution

by:
Dale Burrell earned 500 total points
ID: 39733142
Yes, that exactly what I explained, you put a regular asp.net image button on the page, visible, within the regular asp.net form. And you wire up its client side onclick function to call the javascript code I gave you.
0
 

Author Comment

by:bcrooks
ID: 39735185
That did it - thanks  
working completed code is below

 <asp:ImageButton ID="Button2" src="//someserver.net/images/donate-gray.gif" OnClientClick="script1()" runat="server" />
</div>

 <script type="text/javascript">
     function script1() {
         $('body').append('<form action="https://Simple.net/Payment.aspx" method="post" target="some-name" id="hidden_calc">'
         + '<input type="hidden" name="linkId" value="3e" />'
         + '<input type="submit" name="post form" value="post form" />'
         + '</form>');

         $('#hidden_calc').submit();
         $('#hidden_calc').remove();
         return false;
     };
 </script>
0
 

Author Closing Comment

by:bcrooks
ID: 39735188
Thanks again
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question