为什么表格的形式不会在Internet Explorer中 [英] Why form in a form doesn't work in internet explorer

查看:164
本文介绍了为什么表格的形式不会在Internet Explorer中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从后面code形式添加到 ASP:占位符控制

当我添加表单占位符 <形式的方式> 标签缺失

Asp.net从某种原因将其删除。

但我发现解决方法这一点。我加入(空的形式的):

 <形式为GT;< /表及GT;
<形成......我的形式code来自code背后...

这正常工作在所有浏览器,除了 IE

任何想法如何解决这个 IE

也许这是很重要的)这种形式实际上是一个 PayPal按钮code 并从我的数据源得到它。

我需要添加页面上10个按钮:

 <形式的行动=htt​​ps://www.paypal.com/cgi-bin/webscr方法=邮报TARGET =_顶>
<输入类型=隐藏的名字=CMD.​​.....


解决方案

之一dissadvanced的asp.net web表单的就是只有一个asp.net的形式允许在一个正常的asp.net页。一种形式具有 =服务器和表单中只有asp.net控件正常工作,并与code的后面。

cooporate

但是你可以打破 - 而不是继续有相同的asp.net functionallyty。你可以做的是使用一个LiteralControl而直接在页面上呈现的PayPal按钮code,只有前刚刚通过&LT关闭全球形式; /表> 。只有收盘之前添加新的。

现在你这样做的时候,你必须忘了回发在同一页上,实际上有它仅适用于岗位PP。有一些asp.net页面functionallyty的唯一方式是第一种形式结束前保留它,并设置在web.config中的选项,以防止验证之上。

所以,你开始使用

 <表格名称=aspnetForm方法=邮报行动=?/ UI / login.aspx的RETURNURL = General.aspx>
  ......有些控件回发到ASPX页面
< /表及GT;

和你结束了

 <表格名称=aspnetForm方法=邮报行动=?/ UI / login.aspx的RETURNURL = General.aspx>
  ......有些控件回发到ASPX页面
  ......到这里也许按钮会在页面的工作,之后没有任何更多
 < /表及GT; //< ----您添加
  //跟随贝宝按钮
  <形式的行动=htt​​ps://www.paypal.com/cgi-bin/webscr方法=邮报TARGET =_顶>
  <输入类型=隐藏的名字=CMD.​​..>
  < /表及GT;  //第二个按钮,等
  <形式的行动=htt​​ps://www.paypal.com/cgi-bin/webscr方法=邮报TARGET =_顶>
  <输入类型=隐藏的名字=CMD.​​..>
  < /表及GT;
//现在这种密切的形式是孤儿....
< /表及GT;

替代就可以使后重定向,但需要更多的code和中间页后面创建code贝宝后的数据。下面是一个例子 HTTP:// WWW。 codeproject.com /用品/ 37539 /重定向和-POST-在ASP-NET

您可以用JavaScript做同样的伎俩,用动态的JavaScript创建一个表单,并张贴到PayPal按钮,所有的JavaScript在同一页面上。

我使用所有的技术,所有的人都适用。

I add a form from code behind to asp:PlaceHolder control.
When I add form to placeholder <form> tags are missing.
Asp.net removes it from some reason.

But I have found workaround for this. I have added (empty form):

<form></form>
<form... my form code that comes from code behind...

And this works fine in all browsers except IE!
Any idea how to workaround this in IE.

(Maybe this is important) This form is actually a PayPal button code and I get it from data source.
I need to add 10 buttons on page:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">           
<input type="hidden" name="cmd" ...

解决方案

One of the dissadvanced of the asp.net webforms is that only one asp.net form is allowed in a normal asp.net page. One form that have the runat="server" and inside that form only the asp.net controls correctly work and cooporate with the code behind.

However you can break that - but not continue to have the same asp.net functionallyty. What you can do is to use a LiteralControl and direct render on the page the PayPal button code and only before just close the global form by using the </form>. Only the close just before add the new ones.

Now the moment you do that, you must forget the post back on the same page and actually have it only for post to PP. The only way to have some asp.net page functionallyty is to keep it before the first form close, and set on web.config the option to keep the validation on top.

So you start with

<form  name="aspnetForm" method="post" action="/ui/login.aspx?ReturnUrl=General.aspx" >
  ... some controls that post back to aspx page    
</form>

and you end up with

<form  name="aspnetForm" method="post" action="/ui/login.aspx?ReturnUrl=General.aspx" >
  ... some controls that post back to aspx page    
  ... up to here maybe the buttons will work for the page, after that not any more
 </form> //<---- added by you
  // follow the PayPal buttons
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">           
  <input type="hidden" name="cmd" ... >
  </form>

  // second button, etc
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">           
  <input type="hidden" name="cmd" ... >
  </form>
// now this close form is orphan....
</form>

Alternative you can make post redirect, but require a lot more code and a middle page that create the PayPal post data on code behind. Here is an example http://www.codeproject.com/Articles/37539/Redirect-and-POST-in-ASP-NET

The same trick you can do it with javascript, create a form using javascript on the fly and post that to the paypal button, all on the same page with javascript.

I have use all that techniques, all of them works.

这篇关于为什么表格的形式不会在Internet Explorer中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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