473,385 Members | 1,942 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,385 software developers and data experts.

HowTo: get request.form[i].name

Hello,

HowTo: catch name/value pairs from request.form?

My viewstate shows:
"__VIEWSTATE=..&111=5.."
I want to get this pairs of IDs/names [111] and values [5].
But because the DropDownList ist dynamically created I don't know the
name/ID of the created list. I can parse the viewState string to get the
related name/value pairs, but I think there will be a more simple way
provided by the request-object??

wkr: Wilhelm Pieper
Nov 17 '05 #1
5 8826
Hi,

I don’t know how you get the data from __viewstate field. This data is
handling by the LosFormatter class. This class serializes the values of
the controls into string presentation. The data format in the
__viewstate isn’t in key=value format.

Anyway you can get data from the Form Collection:
string x = Request.form["myTextControl"];

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2

"Natty Gur" <na***@dao2com.com> schrieb im Newsbeitrag
news:eh**************@tk2msftngp13.phx.gbl...

I don't know how you get the data from __viewstate field. .. Debugger :-)
Anyway you can get data from the Form Collection:
string x = Request.form["myTextControl"];

But I don't know the name "myTextControl".
When getting the request.forms string I loop through this string and get
the values I'm looking for but not the names related to this items:
for (int i=0;i<Request.Form.Count;i++)

Double dTmp = Convert.ToDouble(Request.Form[i].ToString());
if (dTmp > 0) ..

Nov 17 '05 #3
OK,

1)using debugger nice :-).

2)What you really after? viewstate will return the last state of the
control on the server while Form collection holds the values that sends
from the client.

Any way if you want you can:
1) Use the LosFormatter class to get the cached data from the
__viewstate field.
2) Loop through the form elements (as you already did) to get the data
Send from the client
3) Loop through the WebForm controls to get their current values (the
cached data and the one that changed by the user).

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #4
Hello Natty,

thanks to your reply.
Because your solution looks a little bit more code I tried
string[] strRequest = Request.Form.ToString().Split('&');

This returns all pairs I'm interested in in an easy to parse array like:
"112=5", "113=4" and so on.
"Natty Gur" <na***@dao2com.com> schrieb im Newsbeitrag
news:#e**************@TK2MSFTNGP10.phx.gbl...
...
1) Use the LosFormatter class to get the cached data from the
__viewstate field. Isn't this the same like Request.Form.ToString()??
2) Loop through the form elements (as you already did) to get the data
Send from the client
3) Loop through the WebForm controls to get their current values (the
cached data and the one that changed by the user).

I could (probably) do, but I'm not shure with this because my controls are
added on the fly.
So they may be not part of the controls collection.

wkr: Wilhelm Pieper
Nov 17 '05 #5
I think you have a fundimental misunderstanding of .Net

you DON"T need access to viewstate. The value of your control is
automatically restored in your application on post-back. You query it's
value then.

These three properties should give you what you want

"DropDownControl.SelectedValue"
"DropDownControl.SelectedIndex"
"DropDownControl.SelectedItem"

..Net removes you from dealing with the behind the scene plumbing of the
web - GONE are the days of splitting on "&" etc etc etc.
(unless you are a PHP pup (doh!))
"Wilhelm Pieper" <w_******@web.de> wrote in message
news:ez**************@TK2MSFTNGP12.phx.gbl...
Hello,

HowTo: catch name/value pairs from request.form?

My viewstate shows:
"__VIEWSTATE=..&111=5.."
I want to get this pairs of IDs/names [111] and values [5].
But because the DropDownList ist dynamically created I don't know the
name/ID of the created list. I can parse the viewState string to get the
related name/value pairs, but I think there will be a more simple way
provided by the request-object??

wkr: Wilhelm Pieper

Nov 17 '05 #6

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

Similar topics

3
by: Roberto | last post by:
I have the following problem: I have the following form client side: <FORM.......> <FORM action="./WZUpload.asp" method="Post" enctype="multipart/form-data" WIDTH=100%> <INPUT Type="file"...
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...
4
by: John Marble | last post by:
My system is near finished, it is something quite basic where the users interfer with the data via forms. I want to limit my groups in what they can SEE from the database. Like, I want my...
8
by: Topper | last post by:
Hello. I have simple web folders structure: -ROOT - BIN WebService.dll WebService.asmx I need to use my WebService.dll not in bin folder - for example, in ROOT. How do i this? How can i do...
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: whyyyy | last post by:
USING IIS 5.1, and Windows XP pro, the following form works on my system, and I can use as many form elements as I wish, as long as all form elements have the same name: "words", in this example....
7
by: =?Utf-8?B?QVRT?= | last post by:
HOWTO Make CStr for JavaScript on ASP w/ Request.Form and QueryString In ASP, Request.Form and Request.QueryString return objects that do not support "toString", or any JavaScript string...
6
by: fnoppie | last post by:
Hi, I am near to desperation as I have a million things to get a solution for my problem. I have to post a multipart message to a url that consists of a xml file and an binary file (pdf)....
2
by: MDANH2002 | last post by:
Hi From VB.NET I want to simulate the POST request of the following HTML form <html> <title>HTTP Post Testing</title> <body> <form action=http://www.example.com/postdata ...
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: 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...
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: 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
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.