Solved

How to exclude some input from post?

Posted on 2009-05-11
9
651 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

828 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