Results 1 to 4 of 4

Thread: how to iterate over controls in page to set properties

Threaded View

  1. #1

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Resolved how to iterate over controls in page to set properties

    using: asp.net 2.0 - [vs2005]

    I have a page with a master template named "MasterPage.master" and want to iterate over all of the controls in the Page to set a property.

    I tried using this in the Page Unload event:

    VB Code:
    1. Dim ctlControl As System.Web.UI.WebControls.WebControl
    2.         For Each ctlControl In Page.Controls
    3.             ctlControl.Enabled = False
    4.         Next

    but this gives an exception:

    Unable to cast object of type 'ASP.masterpage_master' to type 'System.Web.UI.WebControls.WebControl'.

    I tried removing the Master template
    but I still get same error but instead of 'ASP.masterpage_master' it
    refers to Literal Control.

    Am I missing something here?

    Please help. Thanks in advance.
    Attached Images Attached Images  
    Last edited by ZeBula8; Mar 3rd, 2007 at 10:58 PM. Reason: resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width