Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to read a sumitted form..

Status
Not open for further replies.

Dobly

Programmer
Joined
Oct 11, 2003
Messages
7
Location
AU

You may have seem my post a little earlier, where my form had no veiwstate and was not posting any data back. I seemed to have that working now, but now there is a new problem.

I cannot read the submitted values...

Just to summarise, my form is in a nested user control. One that is 'loaded' by another user control , that is in turn, loaded by a base class. Something like that anyway.


I have put the following code in the Page.Load function of the user control with the form.

if (Page.IsPostBack)
{
temp = Request.Form.ToString();
strAmount = Request.Form["txtAmount"].ToString();
etc etc...

When I use the degugger to see the value of 'temp', this is what I see.. (Only the first part is shown here as it is a quite a long form)


"__VIEWSTATE=dDwtMTI3OTMzNDM4NDs7PrggHXYdc%2bfYaBGqGEob%2fwbeSdup&_ctl5%3a_ctl0%3a_ctl0%3atxtAmount=234& etc etc...

See the bit there 'txtAmount=234'? Thats the value I want... But the line...

strAmount = Request.Form["txtAmount"].ToString();

.. returns this error.

System.NullReferenceException: Object reference not set to an instance of an object.

Please help. I am at my wits end with this.
 
Thanks for that. But when i tried youe line of code,

strAmount = CStr(ViewState("txtAmount"));

I got this error on compile.

(65): 'System.Web.UI.Control.ViewState' denotes a 'property' where a 'method' was expected
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top