server crashes when I access a certain control

Discussion in 'ASP .Net' started by Boban Dragojlovic, Jul 28, 2003.

  1. 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?
     
    Boban Dragojlovic, Jul 28, 2003
    #1
    1. Advertisements

  2. 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
     
    William F. Robertson, Jr., Jul 28, 2003
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.