Solved

another form in a asp.net page

Posted on 2013-12-19
7
336 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now