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

ASP.NET 1.1 - Exceptions and Request.Form Question

I have a form that contains a mix of dynamic controls and declared controls.
All of them are intrinsic .NET controls. Several functions within the page
use Request.Form to query the value of the dynamic controls when the page is
posted back.

I also have a server side function that validates data ensuring it falls
within a given range after the post back. If the range is not valid, I am
Throw-ing a new Exception object; the validation occurs within a Try/Catch
block. The error text is written to a Label and the user is given the
opportunity to fix the value and repost the form.

When the form is reposted, the Request.Forms collection is empty and I get
"Object Reference Not Set..." errors when I try to query
Request.Form("dynamiccontrolname"). If I reload the page, the form attempts
to postback and I continue to get these errors.

Is this behavior by default? Why would Exceptions, if caught and the page
returned to the user in the same state, cause the collection to vanish?

Mar 9 '06 #1
2 1570
Request.Form is a collection of the name/value pairs the browser sent on the
request. the only sends them when a form.submit() is done, either thru
javascript (say a asp.net control postback), or subit bullton pressed.

the browser then sends all named, and enabled <input> and <select> controls
in the form to the server as name/value pairs.

-- bruce (sqlwork.com)


"Elliot Rodriguez" <elliotrodriguezatgeemaildotcom> wrote in message
news:OK**************@tk2msftngp13.phx.gbl...
I have a form that contains a mix of dynamic controls and declared
controls. All of them are intrinsic .NET controls. Several functions within
the page use Request.Form to query the value of the dynamic controls when
the page is posted back.

I also have a server side function that validates data ensuring it falls
within a given range after the post back. If the range is not valid, I am
Throw-ing a new Exception object; the validation occurs within a Try/Catch
block. The error text is written to a Label and the user is given the
opportunity to fix the value and repost the form.

When the form is reposted, the Request.Forms collection is empty and I get
"Object Reference Not Set..." errors when I try to query
Request.Form("dynamiccontrolname"). If I reload the page, the form
attempts to postback and I continue to get these errors.

Is this behavior by default? Why would Exceptions, if caught and the page
returned to the user in the same state, cause the collection to vanish?


Mar 9 '06 #2
Bruce:

I know what youre saying, but the sequence of events the way I am seeing it
should still send the collection.

1. Input made
2. Form submitted
3. Is input valid?
3a. Yes, finish processing
3b. No, Throw Exception object and give user opportunity to finish and
repost.
4. Repost form using SAME postback method

The error only occurs when I Throw an exception and attempt to reprocess the
form and I try to access values in the collection. Any other postback method
outside of that lets me access the values fine, which leads me to wonder if
on the Throw the collection is immediately cleared for some reason. My flow
of control codewise never changes - only this Throw causes the issue.
"Bruce Barker" <br******************@safeco.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Request.Form is a collection of the name/value pairs the browser sent on
the request. the only sends them when a form.submit() is done, either thru
javascript (say a asp.net control postback), or subit bullton pressed.

the browser then sends all named, and enabled <input> and <select>
controls in the form to the server as name/value pairs.

-- bruce (sqlwork.com)


"Elliot Rodriguez" <elliotrodriguezatgeemaildotcom> wrote in message
news:OK**************@tk2msftngp13.phx.gbl...
I have a form that contains a mix of dynamic controls and declared
controls. All of them are intrinsic .NET controls. Several functions
within the page use Request.Form to query the value of the dynamic
controls when the page is posted back.

I also have a server side function that validates data ensuring it falls
within a given range after the post back. If the range is not valid, I am
Throw-ing a new Exception object; the validation occurs within a
Try/Catch block. The error text is written to a Label and the user is
given the opportunity to fix the value and repost the form.

When the form is reposted, the Request.Forms collection is empty and I
get "Object Reference Not Set..." errors when I try to query
Request.Form("dynamiccontrolname"). If I reload the page, the form
attempts to postback and I continue to get these errors.

Is this behavior by default? Why would Exceptions, if caught and the page
returned to the user in the same state, cause the collection to vanish?



Mar 9 '06 #3

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

Similar topics

6
by: Iain | last post by:
Hey folks, (I posted this in microsoft.public.dotnet.csharp.general yesterday, but it appears that this group is rather more lively) For the application I am developing, I have a data access...
10
by: Jeff | last post by:
I'm just starting to work with UserControls and have a question on the behavoir of exceptions within UserControls and VS.Net 2003. I have noticed that when a UserControl throws an exception from...
2
by: Juan Dent | last post by:
Hi, How does one handle exceptions in a Web application? For instance, I have a Page_Load method that throws an ArgumentNullException on some ocassions and I have set the Web.config file with a...
6
by: Leslie | last post by:
I am attempting to handle errors by using Application_Error. This seems to work fine in most situations. However, if the exception occurs during the Application_Start method, the stand error...
0
by: boxboy | last post by:
Hi, I'm writing a console application and am having a problem with HttpWebRequest when posting data to a webserver. A "System.Net.WebException: The server committed a protocol violation" is always...
8
by: Richard Collette | last post by:
When attempting to debug a webservice, I get the error: Cannot serialize member System.Exception.Data of type System.Collections.IDictionary, because it implements IDictionary. In reading...
4
by: Steve | last post by:
I have read a couple articles online, read my Jesse Liberty book but I am still confused as to just what the best practices are for using exceptions. I keep changing how I'm working with them and...
2
by: Chuck Bowling | last post by:
In studying for the 70-316 I ran across the question below. I'm a little confused by the 'correct' answer. Why is it necessary to wrap the Validate method in a try/catch block? Doesn't the...
9
by: paul | last post by:
Hi I would like to extract all possible exceptions for a particular method. Ideally this would be a Visual Studio 2005 Add-In and would allow a developer to highlight a any method, pressing a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.