Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
05-27-2012, 11:40 AM #1
- 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" p.Form.Controls.Add(myLabel) End Sub End Class
Please can you help? Thanks