ASP.NET 1.1 - Exceptions and Request.Form Question

  • Thread starter Elliot Rodriguez
  • Start date
E

Elliot Rodriguez

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?
 
B

Bruce Barker

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)
 
E

Elliot Rodriguez

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top