Hi...
App Type: Web Application
SDE: Visual Studio 2008 Pro Edition
Code: asp.net and c#
Using IE 8
I am having an issue in a web based application that I have written that I might be able to better resolve if I understand the exact steps that unfold when someone clicks a submit button that has an event tied to it's click handler. I can find heaps of details on the Page Life cycle itself and what stage does what however when does the actual code for the event tied to the submit button's click handler happen? Sorry if the next question sounds stupid however does the event fire in the same thread as the page cycle or seperately?
That aside I should clearly describe my actual issue as it might not even be related to this. What I am doing is creating dynamic controls based off the contents of an XML file at Page_Load (during non postback). As I create each dynamic control I add them to a main Panel (which is attached to the main page) and I add each control to an ArrayList Session-Variable (see code below). I then use this Session-Variable in a method that then readds the dynamic controls to the Main Panel during the Page_Load event (during postback).
In the OnClick event attached to the Submit button I then check the state of the controls (please note the controls mainly consist of CheckBox Lists and Radio Button Lists) and display a message using a label depending on the results. This works great in around 90% of cases however 3 specific computers around the office receive an error during a call to FindControl inside the OnClick event handler and if I test by reiterating through all controls (including children) on the page it seems none of the dynamic controls exist at that stage inside the event handler. The problem is specific to those 3 particular machines and will always fail (not intermittent) and no clearing of IE cache, restarting the machine will make it work. We run a Standard Operating Environment so everyone has the same build which is XP (service pack 3) running IE 8.
To make matters even more strange (and this is where I am really at a loss) if I make a copy of the aspx and cs file and change its name and then get the same problem machines to run the copy, it then works fine?? However I am not happy with just leaving it at that as I think this error will raise itself again as i think it may be a timing issue in terms of the event. Also we have tried restarting IIS services on the server hosting the web app.
I haven't added too much of my code as i didn't want to make this post too long winded and thought that any code snippets would simply reiterate what I describe above. If someone thinks my c# code would help let me know and I will send through a few more snippets of how I'm going about this.
Code snippet where I add control to session var
if ((ArrayList)Session["dynamicControlsArray"] == null)
{
ArrayList arr = new ArrayList();
Session["dynamicControlsArray"] = arr;
}
((ArrayList)Session["dynamicControlsArray"]).Add([nameOfControl]);
Code snippet of Page_load event:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
ReaddDynamicControls();
}
else
{
Session["dynamicControlsArray"] = null;
PopulateForm();
}
Thanks for taking the time to read this and have a great day!
Danny