Solved

How to exclude some input from post?

Posted on 2009-05-11
9
647 Views
Last Modified: 2013-12-12
1-I have one form with several text inputs.
2-I'm using POS ACTION.
3-I want that some inputs dont go to the POST array.

How do I do that?
0
Comment
Question by:DLJB
9 Comments
 
LVL 39

Accepted Solution

by:
abel earned 250 total points
ID: 24353472
Do not set their runat="server" value, if you create these items declaratively in the HTML of the ASPX, or change them from being an input type to being a (hidden) label type, which will not become part of the POST array.
0
 
LVL 12

Expert Comment

by:alien109
ID: 24353592
try setting their disabled property on submit

<script type="text/javascript">
function disable() {
    document.getElementById("bob").disabled = true;
}
</script>

<form id="test" action="" onsubmit="disable()">
<input type="text" name="bob" id="bob" value="" />
</form>
0
 
LVL 14

Expert Comment

by:shobinsun
ID: 24353597
Hi,

As mentioned from the previous post, you can use the hidden fields . but make sure that name attribute is not set  to the hidden field.
If they don't have a "name" attribute, they won't be submitted (will not be in the POST array).
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Closing Comment

by:DLJB
ID: 31580099
Thanks!
0
 
LVL 39

Expert Comment

by:abel
ID: 24353652
the information from shobinson is correct for internet explorer only. firefox will send the ID if the name is not present. And if you use only an ID on an element that is server-sided (i.e. runat="server") then, for all input types, ASP.NET will automatically add the Name as well, which means: you need some extra tweaking for that hack to work... ;)
0
 
LVL 39

Expert Comment

by:abel
ID: 24353660
@alien109: a disabled element will still be sent to the server in the POST. It is, however, disabled for receiving user input.
0
 
LVL 12

Expert Comment

by:alien109
ID: 24354048
0
 
LVL 39

Expert Comment

by:abel
ID: 24354167
Interesting. Apparently I am mixing readonly/disabled. The key line here is "Controls that are  disabled cannot be successful." (and successful means: cannot be submitted). Thanks for pointing that out to me.
0
 
LVL 12

Expert Comment

by:alien109
ID: 24354919
No problem abel. I've used this technique quite a bit in the past, so I was a bit nervous when you said that :) Had to do some quick tests and research!
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ebay api to see some data about my customers 2 30
Changing Two Areas of a Page 5 17
google analytics in wordpress 4 35
Place text over image using CSS 6 44
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question