server crashes when I access a certain control

B

Boban Dragojlovic

I have the following control defined (among others) ... it represents the
active form on the ASP

Protected WithEvents frmMain As System.Web.UI.HtmlControls.HtmlForm

Then I have this

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Page.IsPostBack Then
For Each ctl As WebControl In Me.frmMain.Controls
If ctl.CssClass = "FieldInError" Then
ctl.CssClass = ""
End If
Next
End If

End Sub



The "for each" loop is just designed to clear up any "highlighting" I may
have done during a previous round trip.

When this code is executed, the 'for each ....' statement crashes ASP.NET

The error in the Application Log says that it was recycled because it sucked
up too much memory. I watched it. It goes from 30k to 360k within a couple
of seconds.

I stepped through this code, and it never gets to the 'if ctl.cssClass'
statement ... it dies on the 'for each' statement.


Any ideas?
 
W

William F. Robertson, Jr.

Most of the controls in the Controls collection are not going to be
WebControl so it would bomb. Get them as Control and then test for children
and is it a WebControl. You will have to step into the children to get the
controls say...under the HtmlForm control.

bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top