views:

117

answers:

1

I have some terribly written ASP.NET code that is just not working right (go figure). I'm charged with maintaining and bug fixing this code, but I can barely make head or high water of it

Unfortunately I don't have the time to rewrite it.

If someone could help this would be great:

(the code): given to you here (some minimal obfuscation necessary): http://mastergeektheater.com/issues.txt

What it's supposed to do: Receives an order from a shopping cart application, and creates a table of textboxes based on the quantity of said object ordered. Once the whole thing is validated (submit_Click()), then it reveals a div with further instructions and grays out the input fields so you can still see what was entered, but can't affect anymore. Emails are sent to each inputted email address.

What it actually does: Receives the order, and correctly displays the inputs. On Submit, all of the "required field validators fire - if they are Vaild, then the comparison validators fire. SOMEWHERE AROUND HERE, it all goes south."

All of the input areas in the table except the first user disappear. if the comparisons success, then it postsback, and the first user is there (greyed out) and the other users are gone. if the comparisons fail, then it doesn't successfully postback, and stays on the input form, but all of the input fields except the first user still disappear

I know this is a little too specific to be a really well formed Stack Overflow question, but I've tried to break it down to things I think were wrong and I asked other questions that were more specific to try to fix it. Unfortunately, it hasn't worked. The code got better, but the whole thing is still broken. At this point I'm desperate.

If anyone could help, it would be a huge lifesaver. Thanks in advance for all of you who pour through this terrible code (and terrible question) for even a minute...

A: 

I guess the problem could be due to this line.

Session["quantity"] =(null != Request["quantity1"]) ? Request["quantity1"].ToString() : "1";

Do you have a field (hidden/input) named quantity1 on the form?
Is it being passed to querystring or as part of form item collection?

It will be 1 (when the form posts back to itself) & hence the loop will only run once.

shahkalpesh
That code is in the preInit phase: I thought it wound't fire on a postback. Do I just have to add if(!IsPostBack) ??
Matt Dunnam
Well I am not sure of it. You can put the code in debug mode to see if it hits preInit on postback.
shahkalpesh
it does hit preinit on postback... and Init... I thought those were supposed to be skipped on postback...hmm...
Matt Dunnam