服务器更改表单字段的名称 [英] Server altering name of form fields
问题描述
[第三次尝试 - 我的前两次尝试似乎没有显示
up -yet]
我有一些代码将一些额外的控件(特别是
普通< input type =" hidden" name =" MyField" form fields)插入到现有的
HTML表单中。然而,它正在破坏名称&这些控件的ID当它们呈现为
时:
例如,PPItemName字段呈现为:< input
名称= QUOT; ctl00 $ $ MainBodyContent&PPItemName QUOT; type =" hidden"
id =" ctl00_MainBodyContent_PPItemName" />
通常,我不在乎(也没关系),但是这个表格
发布到Paypal服务器和paypal期待特定字段
名称 - 因此我们遇到了问题。
我能理解.NET需要使用ID属性,但是为什么名字
属性? name属性在标准HTML中很重要,但我不会因为.NET而想到
。
解决方法是使用占位符,并使用.innerHTML在内部注入
直接HTML。但是这整段代码已经是一个解决方法
,因为.NET无法处理多个表单,所以我认为必须有一个
的限制来解决这个问题。我必须这样做。
有没有办法可以强制服务器不要更改
字段的名称?
在此先感谢...
克里斯
MainBodyContent
PPItemName" type =" hidden"
id =" ctl00_MainBodyContent_PPItemName" />
通常,我不在乎(也没关系),但是这个表格
发布到Paypal服务器和paypal期待特定字段
名称 - 因此我们遇到了问题。
我能理解.NET需要使用ID属性,但是为什么名字
属性? name属性在标准HTML中很重要,但我不会因为.NET而想到
。
解决方法是使用占位符,并使用.innerHTML在内部注入
直接HTML。但是这整段代码已经是一个解决方法
,因为.NET无法处理多个表单,所以我认为必须有一个
的限制来解决这个问题。我必须这样做。
有没有办法可以强制服务器不要更改
字段的名称?
在此先感谢...
Chris
" CJM" < cj ***** @ removeme-yahoo.co.ukwrote in message
news:6j ************ @ mid.individual.net ...
我有一些插入一些额外控件的代码(具体来说,
普通< input type =" hidden" name =将MyField表单字段转换为
现有的
HTML表单。然而,它正在破坏名称&这些控件的ID在
时呈现:
正确。这是标准行为。
有没有办法可以强制服务器不要更改
字段的名称?
绝对不是!不要尝试 - 你几乎肯定会破坏你的应用程序,如果
你这样做。
通常情况下,我不会''关心(也没关系),但这个表格
发布到Paypal服务器而PayPal期待特定字段
名称 - 因此我们是有问题。
是的 - 一个熟悉的问题...
解决方法是使用占位符,并使用.innerHTML直接在内部注入
。但这整段代码已经是一个
变通方法
,因为.NET无法处理多个表单,所以我认为必须有一个
限制我必须做的事情。
遗憾的是,我不知道你正在尝试做什么的其他任何方式
你继续使用表单提交。
显然,表单提交并不是与PayPal交互的唯一方式...
-
Mark Rae
ASP.NET MVP
http ://www.markrae.net
[A third attempt - my first two attempts doesn''t appear to have shown
up -yet]
I have a bit of code that inserts some extra controls (specifically,
ordinary <input type="hidden" name="MyField"form fields) into an existing
HTML form. However, it is mangling the name & IDs of these controls when
they are rendered:
For example, the PPItemName field is rendered as: <input
name="ctl00$MainBodyContent$PPItemName" type="hidden"
id="ctl00_MainBodyContent_PPItemName" />
Ordinarily, I wouldn''t care (and it wouldn''t matter either), but this form
is posting to a Paypal server and paypal is expecting particular field
names - so consequently we are having problems.
I can understand that .NET needs to use the ID attribute, but why the name
attribute? The name attribute is important in standard HTML, but I wouldn''t
have thought so for .NET.
A workaround would be to use a placeholder, and use .innerHTML to inject
straight HTML inside. But this entire piece of code is already a workaround
for .NETs inability to handle multiple forms, so I thought there must be a
limit to the amount of messing about that I have to do.
Is there a way that I can force the server not to change the name of the
fields?
Thanks in advance...
Chris
MainBodyContent
PPItemName" type="hidden"
id="ctl00_MainBodyContent_PPItemName" />
Ordinarily, I wouldn''t care (and it wouldn''t matter either), but this form
is posting to a Paypal server and paypal is expecting particular field
names - so consequently we are having problems.
I can understand that .NET needs to use the ID attribute, but why the name
attribute? The name attribute is important in standard HTML, but I wouldn''t
have thought so for .NET.
A workaround would be to use a placeholder, and use .innerHTML to inject
straight HTML inside. But this entire piece of code is already a workaround
for .NETs inability to handle multiple forms, so I thought there must be a
limit to the amount of messing about that I have to do.
Is there a way that I can force the server not to change the name of the
fields?
Thanks in advance...
Chris
"CJM" <cj*****@removeme-yahoo.co.ukwrote in message
news:6j************@mid.individual.net...
I have a bit of code that inserts some extra controls (specifically,
ordinary <input type="hidden" name="MyField"form fields) into an
existing
HTML form. However, it is mangling the name & IDs of these controls when
they are rendered:Correct. That is standard behaviour.
Is there a way that I can force the server not to change the name of the
fields?Absolutely not! Don''t even try - you''ll almost certainly break your app if
you do.
Ordinarily, I wouldn''t care (and it wouldn''t matter either), but this form
is posting to a Paypal server and PayPal is expecting particular field
names - so consequently we are having problems.Ah yes - a familiar problem...
A workaround would be to use a placeholder, and use .innerHTML to inject
straight HTML inside. But this entire piece of code is already a
workaround
for .NETs inability to handle multiple forms, so I thought there must be a
limit to the amount of messing about that I have to do.Regrettably, I don''t know any other way of doing what you''re trying to do so
long as you continue to use form submission.
Obviously, form submission isn''t the *only* way to interface with PayPal...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
这篇关于服务器更改表单字段的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!