Reputation: 7953
I have the following code:
private Ext.Net.Store getStore(string name)
{
return (Ext.Net.Store)DUOSPage.FindControl(name);
}
and
getStore("store").DataSource = someList;
I can verify that both the "store" object and "someList" are actually present in the page. It seems to me that FindControl cannot be found. However, am am getting a
someList = Count = Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible, possibly because the code is optimized.
aswell as the local server crashes. To me that means that the element might be in the page and found but it somehow causes the server to cringe and crash.
Any ideas on what is wrong here? Why would this crash the ASPX server?
EDIT:
The error prompt gives me this:
Description:
Stopped working
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: webdev.webserver20.exe
Problem Signature 02: 10.0.0.0
Problem Signature 03: 4ba204ca
Problem Signature 04: ****
Problem Signature 05: 1.0.0.0
Problem Signature 06: 4fe36c1c
Problem Signature 07: 3ce
Problem Signature 08: c
Problem Signature 09: System.NullReferenceException
OS Version: 6.1.7601.2.1.0.256.4
Locale ID: ****
Upvotes: 1
Views: 527
Reputation: 2385
If you're using Ext.NET, or even if you're not, Ext.NET includes the Ext.NET.Utilities library (not dependent on Ext.NET).
The Utilities library includes the ControlUtils
class with a whole pile of "FindControl" helpers to work-around limitations of the native Page.FindControl Method.
There may be an option in ControlUtils
to avoid this issue, although I'd need to see a more complete sample to say 100% what the best solution/call would be. Something like the following might work.
Example
return Ext.Net.Utilities.ControlUtils.FindControl<Store>(this, name);
The ControlUtils.FindControlByClientID(string)
Method might be helpful as well.
https://github.com/extnet/Ext.NET.Utilities (MIT licensed)
Anyways, the native ASP.NET Page.FindControl() is limiting, although there are other options with greater flexibility, and you already have those options available on your Page.
Hope this helps.
Upvotes: 0
Reputation: 7953
For anyone looking for the solution, I found it here:
http://winmike.blogspot.com/2011/02/aspnet-findcontrol-returns-null-for.html
Upvotes: 0
Reputation: 3302
You may be confusing two different things. You mention that you can verify that "store" is present in the page, which I assume means you see it in your HTML markup, but that doesn't necessarily mean it's available to the server. Make sure you set runat="server" to ensure a server-side control is generated for your "store" element.
Upvotes: 1