ASP.NET Doesn't Work Right??
I'm finding that variables I set remain even after I refresh the page.
An example is, I accidentally left a DataReader open, then diplayed the page.
Next, I had the user go back to the server, which runs the Page_Load proc again and try to open a new DataReader.
An error said that a data reader for that connection was already open.
The connection and the DataReader should have been closed because the variables should have been 'un' instantiated. NO?
Also, I had a protected bool FoundOnrBranches which I set as true on a TextChanged event:
<asp:textbox class="formTextBox" id="onrName" runat="server" MaxLength="75" Size="50" AutoPostBack="True"></asp:textbox>
-- Server Code --
private void onrName_TextChanged(object sender, System.EventArgs e)
{
if(onrName.Text != "")
{
GetBranches();
}
}
------------------------
GetBranches() Sets the variable FoundOnrBranches to true.
Then I diplay the page and in inline code I reset it to false.
FoundOnrBranches = false;
I stepped through the code and verified that it was false.
Next I (the user) set another field:
<asp:textbox size="50" AutoPostBack="True" class="formTextBox" id="Addr1" MaxLength="100" runat="server"></asp:textbox>
----- Server Code ----
private void Addr1_TextChanged(object sender, System.EventArgs e)
{
if(Addr1.Text != "")
{
GetComparableProjects();
}
}
---------------------------------------
When I step through the code at this point, on Page_Load, I verified that the variable FoundOnrBranches = false.
BUT - when I SINGLE step (3 steps total) to the Addr1_TextChanged event proc the variable has been reset to true.
I step through it one line at a time.
There is NO CODE that resets it to true.
This only happens if I had set it to true in GetBranches() (above).
The application seems to REMEMBER that it was set to true and even though I manually reset it to false, it automatically resets it to true.
What's Going On?
|