通过代码提交表单? [英] Submit Form via code behind?

查看:52
本文介绍了通过代码提交表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我知道,为什么我要从服务器端代码提交表单,如果获取服务器端代码的唯一方法是提交表单。但就是这样,当代码隐藏的page_load事件触发时,它并​​没有真正提交。我希望它提交的表格。


这是我的问题,我为一个网站制作了一个购物车,为了获得安全支付的信息,我需要发送一个使用method =" post"形成paypal和action =" big long url。在asp.net中,我不能使用runat =" server"在同一个网页上,所以我所做的是创建一个新页面,唯一的形式是send-to-paypal形式,并且代码隐藏中的page_load事件处理程序使用正确的交易信息(项目名称,价格)填充表单标签,运输等)。目前我必须在这里使用type =" submit"创建一个按钮。在将交易发送到paypal之前,您必须单击按钮。有没有办法让Page_Load事件触发表单的提交事件,所以我不需要点击按钮?


这里是html的一部分具有以下形式的新页面:

I know I know, why would I want to submit the form from server-side code, if the only way to get to the server-side code was BY submitting the form. But that''s just it, when the code-behind page_load event fires it doesn''t really "submit" the form as I would like it submitted.

Here''s my problem, I made a shopping cart for a website, and to get the information securely paid for I need to send a form to paypal using method="post" and action="big long url". In asp.net I can''t have multiple forms with runat="server" on the same web page, so what I did was create a new page with the only form being the send-to-paypal form, and the page_load event handler in the codebehind populates the form tag with the correct transaction information (item names, prices, shipping, etc). Currently I have to have it create a button here too with type="submit". You have to click the button before the transaction is sent to paypal. Is there a way to make the Page_Load event fire the form''s submit event so I don''t have to require a button click?

Here''s the html part of the new page with the form:

展开 | 选择 | Wrap | 行号

推荐答案

任何人都可以帮助我这个? :\



我在想,也许我可以在我的网站的body标签中放置某种javascript on_load函数,它会在之后执行 asp创建页面的内容,那会有用吗?如果是这样,我如何制作一个javascript on_load事件:X
Can anyone help me out on this? :\


I was thinking, maybe I could put some kind of javascript on_load function in the body tag of my site, and it would be executed after asp creates the page''s content, would that work? If so, how do i make a javascript on_load event :X


你能解决这个问题吗?如果有,怎么样?我也在寻找答案!
Were you able to resolve this issue? If yes, how? I am looking for an answer as well !!!



你能解决这个问题吗?如果有,怎么样?我也在寻找答案!
Were you able to resolve this issue? If yes, how? I am looking for an answer as well !!!



这个问题的细节很奇怪。在页面加载时提交表单意味着提交表单而不需要任何用户输入,这首先会对表单存在的原因提出质疑。当然可以调用在该页面上提交表单的页面的Javascript函数。

The details of this problem are quite strange. Submitting a form as the page loads means submitting a form without taking any user input at all which brings to question the reason for the existence of the form in the first place. It''s possible of course to call a Javascript function onload of a page that submits a form on that page.


这篇关于通过代码提交表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆