Solved

How to exclude some input from post?

Posted on 2009-05-11
9
642 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
 

Author Closing Comment

by:DLJB
ID: 31580099
Thanks!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to dynamically set the form action using jQuery.

912 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now