I am building a german payment provider into my site.
But when I click on "Submit", nothing happens. Can someone please help me? I think I've looked at it too much and I can't see the forest for the trees anymore...
<form method="post" action="https://www.sofortueberweisung.de/payment/start">
<input name="currency_id" type="hidden" value="EUR" />
<input name="reason_1" type="hidden" value="Zambuu" />
<input name="user_id" type="hidden" value="29593" />
<input name="project_id" type="hidden" value="80145" />
<input type="submit" value="Absenden" />
</form>
Okay, so it's a little bit unclear what I want, it seems:
I have a lot of asp-sites allready, and now I must send, however, the information that is given by the hidden inputs by post-method to the site "sofortüberweisung.de/payment/start".
However I can solve it, it's not nessecary, there is no need for a form-tag, if there is another solution (e.g. with the code behind).
So: How can I send a lot of post information (these here is only an exmaple, in the real site there are a lot more) with code and redirect it to the right site?
If the code you have provided is within a standard ASP.NET form, so that you have nested form tags, try the solutions provided to this Stack Overflow question.
If it is possible to have this page be a simple html form, that is another possible solution.
Your button needs to have the runat="server" attribute set and it might be worth doing the same on your form atttribute.
Also remember in asp.net webforms you can only have one form tag.
I've had this issue a couple of times before where when creating an HTML form inside an ASP.NET form tag, the inner form just wouldn't post out.
One solution for me was to adjust the ASP.NET form tag wrapper for that page (moving the close above the HTML tag).
Another (where I needed ASP.NET controls obove and below the HTML form) was to add an iframe, passing the parameters for the form post to the iframe URL. Using JavaScript, the iframe then used those parameters to post the form to a new window/the parent window. Probably better ways, but it worked for me.
Related
In my project I want to run 2 forms in one webpage which is master page one is for contact us and one is for signup user. but multiple server side forms are not allowed. is there any solution for fix it?
You can use postback ability of Asp.net Webforms.
You should create one button for singup and another one for contact. You can catch event in server side and you do what want to do.
You can create regular client side forms created using HTML in the master page, and use the Request.Form to read the posted data. For this to work, all the input elements must have a name, and you can read them using Request.Form["ElementName"].
Take into account that forms cannot be nested.
So, your master page needs to llok like this
...
<body>
<form id="form1" runat="server">
</form>
<form id="contact" action="Contact.aspx" method="post">
<input type="text" name="Message"/>
<input type="submit" value="Contact us!"/>
</form>
</body>
The first <form> is the regular ASP.NET server side form, which supports server side components
The second <form> is a custom HTML form. It doesn't have the runat="server" attribute, and it's outside the server side <form>.
The second form action points to a .aspx page. In its page load event you can use the Request.Form["Name"] to acces the name of the contact form. Note that you also need to include a submit button to send the data to the server, and a method="post" to specify the method to send the page.
This is resorting to "basic" HTML controls, so there is no View State, and the posted values will be lost if they're not reset in the server. I.e. if the form is posted, and there's an error, the previously posted values will be lost when rendering the page again.
If you want to make it more sophisticated you can use Javascript and, optionally AJAX. But that's a more complex solution. See this for an example.
ASP.NET Forms only supports one form. You could use an iFrame and render your second page (second form) inside of the iFrame.
Here is an interesting post about placing some page content after the tag. This may be helpful to you.
http://forums.asp.net/t/1611822.aspx?Dynamically+adding+content+to+page+outside+of+the+aspnet+form+from+within+a+UC
I am trying to do something from scratch in asp
I would like to get something like below. From basic hard coded values.
http://localhost:2478/Default.aspx?phone=905123456&order=123456
After that I want to use this parameter in my variables for SQLquery
I am new to asp.net and vb , I'm learning. Can you please explain me in details? Any helps will be appreciate.
Can you please provide any basic code from where I can start
Based on your latest comments:
<form method="get" action="default.aspx">
<input type="text" name="phone" />
<input type="text" name="order" />
<input type="submit" value="submit" />
</form>
Key points:
method=get (fields are in url instead of body)
note that the form above doesn't have runat=server (more below) - it's a plain HTML Form on plain HTML page
in the context of ASP.Net Web forms, you may run into issues particularly if you are using Master Pages (you can't nest forms, and a Master page is a container for your entire page).
ASP.Net forms do POSTbacks - re: method=post
You can use/add plain forms in an ASP.Net page as long as you don't nest them (outside of the server side ASP.Net form).
If you have no choice (e.g. Master Page), you'll have to construct the Querystring manually after a POSTback, then Response.Redirect to some other target (adding the querystring manually).
there are other non-ASP.Net-y ways of doing it - e.g. javascript, but that a different story
I have a simple form that passes to an ASPX page to watch a video. The ASPX page uses a hidden field from the form to load the correct video.
This works for me, but a couple other people are the error message because it appears the value isn't being passed. I'm assuming it's a setting in IE... Anyone seen this or know how to fix? OR a better idea?
Simple form on "yourdomain.org"
<form action="http://www.mydomain.org/WatchVideo/Default.aspx" method="post" enctype="multipart/form-data">
<input type="hidden" name="hidden" value="movie.flv" />
<input type="submit" name="submit" value="Watch Video" />
</form>
The ASPX page on "mydomain.org"
If Request.Form("hidden") IsNot Nothing Then
lit.Text = Request.Form("hidden")
Else
Response.Write("Not Authorized. Video Not Passed.")
End If
Sounds and loooks pretty straight forward. Not sure why the same version of IE would have different results. Any other thoughts on how to do this? I need to keep the "off site" coding simple and in HTML for non-technical folks.
Thanks.
It appears to be a setting inside of the browser. I couldn't narrow it down to a specific setting, but once we changed the "Internet" zone to medium from medium-high it began working. It has something to do with posting form data across domains.
in a content page of an asp.net web page, i would like to include the "paypal" button "Pay Now".
So, i've a master page, and a content page.
In my content page i copy-paste paypal code.
In particular i use a "modalpopupextender" to permit my user to buy the object.
The problem is... it not work.
So my hypotheses are:
I'm not sure, but i think i can't use a nested <form action>
If not the first, maybe i can't use a <form action> into a modal popup ?
someone can suggest me an "elegant" solutions to solve this ?
Thank you ...
EDIT: in particular, what i'm trying to do is to permit to sell from a website.
I've a master page, and a content page.
Obviously in master page i've the classical "form action" .
Then i'm gone to paypal and got this code: "
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<table>
<tr><td>
<input type="hidden" name="on0" value="Annuncio Premium">Annuncio Premium
</td></tr>
<tr><td>
<select name="os0">
<option value="Premium 1">Premium 1 €1,00</option>
</select>
</td></tr>
</table>
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="encrypted" value="-----BEGIN ">
<input type="image" src="https://www.paypal.com/it_IT/IT/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - Il sistema di pagamento online più facile e sicuro!">
<img alt="" border="0" src="https://www.paypal.com/it_IT/i/scr/pixel.gif" width="1" height="1">
</form>
So i've pasted it into my content page ... as it... without changing.
In particular i've pasted it, into a panel, that will show whith a "modalpopupextender".
It works. But what it not work is when i click the paypal "Buy Now" button.
My web page don't redirect to paypal, modalpopup disappears and nothing happens.
I had this exact issue too and couldn't believe that PayPal had not provided some sort of solution for .NET developers!!
Here is how I solved it:
<asp:ImageButton ID="btnPayNow" runat="server" ImageUrl="myPayPalButton.jpg"
PostBackUrl="https://www.paypal.com/cgi-bin/webscr" OnClick="btnPayNow_Click"/>
Use an ImageButton or normal button and simply remove the form tags for the PayPal code, leave in the hidden input fields and the data will be posted to the PayPal url!
Nice and easy :)
Ps. The method 'btnPayNow_Click()' does nothing, signature exists but there is no logic in the code I have.
You are quite correct, in that you cannot nest <form>s.
Nor can you use the form action to create a popup - the action attribute is the url to which the form posts to.
You can, however, have many <form>s on the page, so long as they are not nested. Perhaps that will solve you issue.
Can you please describe exactly what you are trying to achieve? It is not clear from your question what the problem is.
If I understand the question correctly, you are trying to create a dynamic HTML popup window which contains a PayPal form. You are having problems because the popup contains a form, but the HTML for the popup is already contained within a form.
If the problem you are experiencing is what I described above, the solution is fairly simple. You need to move all of the HTML for the popup outside of the exiting form element. If you are using CSS to properly lay out your site, it should be possible to display your dynamic popup wherever you need to on the page using relative or absolute positioning. The HTML for the popup need not be contained within another form. It may also be possible (perhaps even necessary) to put the contents of the popup into an iframe, which can be submitted entirely independently from the rest of the page. The semantics of how your popup works would depend on how you need your page to function.
So, to be clear...it is not possible to nest form elements. However, it is also not necessary to accomplish your needs.
EDIT:
To improve the answer above in light of the updated question. You can have multiple content panels on a master page. It should be entirely possible to create another content panel that is outside of your form element in your master page...and place your modal popup inside of this alternative content panel. My above answer would then still apply, as you no longer have nested forms.
You are right in your first hypothese, you can't have nested form tags in a page.
You just have to put the code for the popup outside the form, you can have any number of forms in the page as long as they are not nested.
Dal's answer is correct! (not taking credit with my answer)
I had a similar issue in ASP.NET (4.0) when trying to submit data to SagePay (same as PayPal form posting). I was writing the form fields in dynamically using panels in the code-behind using
Dim Panel As New Panel
Panel.Controls.Add(New LiteralControl("My <input> controls HTML")) '1 control.add per <input> control.
MyDiv.Controls.Add(Panel)
I was writing the whole < form> dynamically also, so when it came to debugging I received no warnings regarding the issue that my entire Site.Master is within a - this is not visible from a .aspx page using the master as a template! It was quite frustrating... Until I read that you cannot have a nested < form>... There are only two alternatives to this:
1) move the form details outside the first that is within my Site.Master from the .aspx page itself. (I didn't like the idea of this, messy messy!)
2) create another control that is NOT a to post my data.
I chose the latter!
<asp:Button id="btn_payment" value="Proceed to Payment" Text="Proceed to Payment" runat="server" PostBackUrl="https://test.sagepay.com/gateway/service/vspform-register.vsp" />
The button posted to SagePay, took my dynamically generated fields (Called from the .aspx page) and as they were already within the from my Site.Master - all worked well! - I hope this helps anyone using dynamically generated HTML with forms.
I have a classic asp application. I want to post a contest form from that page to an Asp.Net form. The reason is that I want to use a lot of logic i have built into an Asp.Net page for validation before entering into the database and I don't know asp very well. Not to mention asp.Net being more secure.
What's the best way to accomplish this goal? My thoughts are as follows:
My asp Page:
<html>
<body>
<form action="/Contests/entry.aspx" method="post">
Name: <input type="text" name="fname" size="20" />
Last Name: <input type="text" name="lname" size="20" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
aspx page is running in a Virtual Directory and would handle anything posted to it.
Is this possible, or does aspx prevent this kind of thing?
I ( preferably ) don't want to create the form in aspx as my colleague wants to have control of the page and build the html himself and I don't want the hassle of constantly changing it.
Are there caveats I need to consider?
What roadblocks will I run into?
How do I access the Posted Form Values? Request.Form?
Yes it is possible. In general, a POST is a POST. So you can post from a PHP page to a .NET page if you wanted. You would access the Request.Form variables just as you do now. You will have to look at the ASP Classic page to see the names of the post items but in general, you can access them as if you had pasted from .NET page.
This can be done and works fine. You will access the Posted Form values as you said via Request.Form.
I think the biggest caveat is that you will need to handle invalid data in some way - typically with a webform the .aspx page would be displayed again with validation errors, but that would likely be inappropriate for your circumstance. Probably you will need to redirect them back to the .asp page with query string parameters indicating the failures and the page will need code allowing it to fill in the form fields with their previous values and display the error message.
How about calling an ASP.NET webservice from classic asp?
https://web.archive.org/web/20210125161040/http://www.4guysfromrolla.com/webtech/070302-1.shtml