473,383 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

RE: Server Renaming Form Fields

asp.net munges the name, because this is what the browser posts. remember
forms can not be nested, so the placeholder must be outside the form.

you could create you own naming container, that did not munge the names or
better yet create a pay pal control, that render the form and the hidden
fields.

pretty trival:

public class paypal : WebControl
{
public string Field1 { get; set; }
public string Field2 { get; set; }
protected override HtmlTextWriterTag TagKey
{
get { return HtmlTextWriterTag.Form; }
}
public override void RenderBeginTag(HtmlTextWriter writer)
{
writer.AddAttribute("action", "https://someurl");
writer.AddAttribute("method", "post");
base.RenderBeginTag(writer);
}
protected override void RenderChildren(HtmlTextWriter writer)
{
renderHidden(writer, "field1", Field1);
renderHidden(writer, "field2", Field1);
}
private void renderHidden(HtmlTextWriter writer, string name, string
value)
{
writer.AddAttribute("type", "hidden");
writer.AddAttribute("name", name);
writer.AddAttribute("value", HttpUtility.HtmlEncode(value));
writer.RenderBeginTag("input");
writer.RenderEndTag();
}
}

-- bruce (sqlwork.com)
"CJM" wrote:
[A second attempt - my first attempt 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
Sep 23 '08 #1
0 886

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
1
by: ij | last post by:
Hi, I'm trying to submit an image object, along with some other text fields to another web server from within an ASP page but am stuck on getting the image to be submitted with the form. In a...
1
by: Don Leverton | last post by:
Hi Folks, I have been given a CD with approx 130 .xls files (bean-counters!) that I would like to import and merge to ONE table (tblTradeshow). The XL files are *similarly*, but not...
2
by: Francois | last post by:
Hi, I have a form which contains some non server side controls. I have seen in the generated HTML of a page that non server side controls can be read by the server code (C# or VB.NET) as the...
22
by: Mr Newbie | last post by:
I was thinking about developing a workflow application yesterday and was musing over the different approaches than one could take in restricting specific actions on a ticket( Form ) at any said...
8
by: BillCo | last post by:
I'm updating a legacy app with table naming that makes baby jesus cry. It's a bit of a spider web though... no telling when and where the tables will be called by name. So I wrote this for renaming...
3
by: Shepherd.Travis | last post by:
I'm attempting to rename a Windows 2003 Server machine that has DB2 9.1 Express with Fixpack 2 installed. After I rename the machine and reboot, I get an error: DB2 UDB: SQL1042C An unexpected...
0
by: =?Utf-8?B?YnJ1Y2UgYmFya2Vy?= | last post by:
this was answered last time you asked. -- bruce (sqlwork.com) "CJM" wrote:
3
by: graphicssl | last post by:
Okay, so first of all, I'm a designer first and a light coder second (I'm only really trained with HTML and CSS). So I apologize for having to post about something that's probably super-trivial! ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.