473,396 Members | 2,052 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,396 software developers and data experts.

Request.Form Loop Question

I have searched alot for this and cannot find an answer. I have a
simple form, and when it submits, I have it posting the data. I have a
simple function to loop through and print out all my form data:

<table class="data" width="90%">
<tr>
<th>Name</th>
<th>Value</th></tr>

<% string val;
foreach ( string name in Request.Form.AllKeys)
{
if (name != "" )
val = Request.Form[ name ] ;
else val = "&nbsp;"; %>
<tr>
<td><%= name %></td>
<td><%= val %></td></tr>
<% } %>
</table>

If that looks familiar, that is because I robbed it from a tutorial
site. :) Anyway, the problem is that I get garbage that looks like this
when I run it:

Name Value
__VIEWSTATE /wEPDwUJODI3NTcxMjc...
txtFName
txtLName
txtEmailBody
__EVENTVALIDATION wEWBALnqp3/DwK7zqYkArvO7sc...

I realize that I could just use if statements to ignore any names of
"__VIEWSTATE" or "__EVENTVALIDATION", but I was using some VB code
previously called gdform.asp, which did the same exact logic, but it
did not have to account for these two variables. What is going on, and
is there a cleaner way than using if statements to ignore these
variables?
Thanks in advance,
John

May 10 '06 #1
4 13516
John,
In Asp.net there is feature what we call ViewState, This feature is used to
presist data between requests to the webserver for the particular page. Hence
you can notice that when you enter any value in server side control and when
the page is submitted to the server and comes again to the client, those
values are still in the control, this is all Handled by the ViewState. Now
coming to this Garbage looks, actually ViewState is Hashed Data, so if hacker
views the sourcecode he cant understand or temper it. You can Disable
ViewState by properties Window of Page

"just.an.imbecile" wrote:
I have searched alot for this and cannot find an answer. I have a
simple form, and when it submits, I have it posting the data. I have a
simple function to loop through and print out all my form data:

<table class="data" width="90%">
<tr>
<th>Name</th>
<th>Value</th></tr>

<% string val;
foreach ( string name in Request.Form.AllKeys)
{
if (name != "" )
val = Request.Form[ name ] ;
else val = " "; %>
<tr>
<td><%= name %></td>
<td><%= val %></td></tr>
<% } %>
</table>

If that looks familiar, that is because I robbed it from a tutorial
site. :) Anyway, the problem is that I get garbage that looks like this
when I run it:

Name Value
__VIEWSTATE /wEPDwUJODI3NTcxMjc...
txtFName
txtLName
txtEmailBody
__EVENTVALIDATION wEWBALnqp3/DwK7zqYkArvO7sc...

I realize that I could just use if statements to ignore any names of
"__VIEWSTATE" or "__EVENTVALIDATION", but I was using some VB code
previously called gdform.asp, which did the same exact logic, but it
did not have to account for these two variables. What is going on, and
is there a cleaner way than using if statements to ignore these
variables?
Thanks in advance,
John

May 10 '06 #2
asp.net as opposed to classic asp has a number of system generated hidden
fields such as view and the field used to validate the events. You are
retrieving these and these fields cannot be disabled. If you really want to
loop through all the fields on a page, I would suggest that you prefix your
fields with some unique name such as "MyField_" and then test for that when
you get a field.

--

Andrew Robinson
www.binaryocean.com
"just.an.imbecile" <jo******@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
I have searched alot for this and cannot find an answer. I have a
simple form, and when it submits, I have it posting the data. I have a
simple function to loop through and print out all my form data:

<table class="data" width="90%">
<tr>
<th>Name</th>
<th>Value</th></tr>

<% string val;
foreach ( string name in Request.Form.AllKeys)
{
if (name != "" )
val = Request.Form[ name ] ;
else val = "&nbsp;"; %>
<tr>
<td><%= name %></td>
<td><%= val %></td></tr>
<% } %>
</table>

If that looks familiar, that is because I robbed it from a tutorial
site. :) Anyway, the problem is that I get garbage that looks like this
when I run it:

Name Value
__VIEWSTATE /wEPDwUJODI3NTcxMjc...
txtFName
txtLName
txtEmailBody
__EVENTVALIDATION wEWBALnqp3/DwK7zqYkArvO7sc...

I realize that I could just use if statements to ignore any names of
"__VIEWSTATE" or "__EVENTVALIDATION", but I was using some VB code
previously called gdform.asp, which did the same exact logic, but it
did not have to account for these two variables. What is going on, and
is there a cleaner way than using if statements to ignore these
variables?
Thanks in advance,
John

May 10 '06 #3
> asp.net as opposed to classic asp has a number of system generated hidden
fields such as view and the field used to validate the events. You are
retrieving these and these fields cannot be disabled. If you really want to
loop through all the fields on a page, I would suggest that you prefix your
fields with some unique name such as "MyField_" and then test for that when
you get a field.

--

Andrew Robinson
www.binaryocean.com

Or the other way around: ignore if it starts with "__".

Hans Kesting
"just.an.imbecile" <jo******@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
I have searched alot for this and cannot find an answer. I have a
simple form, and when it submits, I have it posting the data. I have a
simple function to loop through and print out all my form data:

<table class="data" width="90%">
<tr>
<th>Name</th>
<th>Value</th></tr>

<% string val;
foreach ( string name in Request.Form.AllKeys)
{
if (name != "" )
val = Request.Form[ name ] ;
else val = "&nbsp;"; %>
<tr>
<td><%= name %></td>
<td><%= val %></td></tr>
<% } %>
</table>

If that looks familiar, that is because I robbed it from a tutorial
site. :) Anyway, the problem is that I get garbage that looks like this
when I run it:

Name Value
__VIEWSTATE /wEPDwUJODI3NTcxMjc...
txtFName
txtLName
txtEmailBody
__EVENTVALIDATION wEWBALnqp3/DwK7zqYkArvO7sc...

I realize that I could just use if statements to ignore any names of
"__VIEWSTATE" or "__EVENTVALIDATION", but I was using some VB code
previously called gdform.asp, which did the same exact logic, but it
did not have to account for these two variables. What is going on, and
is there a cleaner way than using if statements to ignore these
variables?
Thanks in advance,
John

May 10 '06 #4
Thanks for all the advice. I will simply tell it not to get anything
that starts with __.

Andrew - Judging from the way you worded this "If you really want to
loop through all the fields on a page..." I'm assuming there is a
better way? I'm simply trying to gather the form info and then use it
to generate a simple email to myself.

May 10 '06 #5

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

Similar topics

2
by: Harag | last post by:
Hi All Using: JScript IIS 5 I have a problem in the following code: // The next 4 lines display exactly what was typed in the text boxes. out("<br>Request.Form="+...
4
by: Paxton | last post by:
At the risk of being told "If it ain't broke, don't fix it", my code works, but is ugly. Part of the admin site I'm working on at the moment includes a facility for users to enter Formulations...
5
by: Jack | last post by:
Hi, I am trying to get a thorough understanding of a code where a addition or deletion of records can be done from a list of records. For addition part of the form, data is being obtained from set...
14
by: BJ Freeman | last post by:
I have passed a form with a post. the form is generated from a dB and can change. the page that accepts the post must get the input name and value from the form passed to it. Request.Form(I)(1)...
14
by: Drew | last post by:
I need to iterate through a submitted form, inserting data on each pass. In the past, I have always used form elements that were named with numbers at the end, like this, name1 relationship1...
4
by: Michael Kujawa | last post by:
I am using the following to create an SQL statement using the names and values from request.form. The loop goes through each item in request.form The issue comes in having an additional "and" at...
3
by: G | last post by:
Hello, I have a c# ASPX file, and a Code Behind file. This file has contents POSTED to it, around 15 form fields. Rather than manually catch each Request.Form - is there an easy way to...
3
by: David | last post by:
Hi, I have some code in my form as follows, to display 1 to 20 additional sets of fields to enter guest information. I am not sure how to retrieve these guests info so that I can post the info...
6
by: magix | last post by:
Hi, Can I: <script language="javascript"> var TimeSec = new String (Request.form("TimeInSec")); or
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.