Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Mar 2012
    Thanked 0 Times in 0 Posts

    Add dynamic Control from a class only

    Hi,Please can you help

    I'm trying to add a control to alot of pages dynamically from an object.

    error :The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

    • I cant remove the code blocks <% = %> - because there are to many pages to edit
    • I cant add a place holder - because there are to many pages to edit
    • Everything must be added from my class

    I have attached a simple example project.

    Public Class MyObject
        Public Sub AddControl()
            Dim p As Page = HttpContext.Current.CurrentHandler
            Dim myLabel As New Label()
            myLabel.Text = "Sample Label"
            myLabel.ID = "test"
        End Sub
    End Class

    Please can you help? Thanks
    Attached Files Attached Files


Posting Permissions

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