Create and display a Webcontrol created dinamically

  • Thread starter Thread starter Cesar Ronchese
  • Start date Start date
C

Cesar Ronchese

Hello.

I have a WebForm that contains a Panel object. This panel, at design time is
empty. When running, I need to create dinamically a Label and a WebControl
(built from the same project).

I can create the label and the webcontrol dinamically with no errors, but
only the Label appear in the panel when the page is shown in the client
browser.

How can I resolve that, so the WebControl be shown?

Ps.: some piece of code:
Private sub Page_Load(...)
'the label is ok
dim lbl as new Label
lbl.Text = "Test"
lbl.Visible = True
panPanel.Controls.Add(lbl)

'the webusercontrol is not ok (do not appear in the page)
dim ctr as new MyWebControl
ctr.Visible = True
panPanel.Controls.Add(ctr)
End Sub

(VS 2005 Standard)

[]s
Cesar
 
Cesar,

Did you make your own class from the webbrowser?
dim ctr as new MyWebControl

That thing is allready difficult enough to handle not inherited.

However just my opinion.

Cor
 
Nah, its just a single a randomic name for the webcontrol (WebUserControl). I just added it to project via "Add New Item" menu and choosing WebUserControl from pallete.
:P
 
Cesar,

If I than understand you well, than you can not do this. It is already there so it is.

MyWebControl.visible = true

Cor
"Cesar Ronchese" <info||carsoftnet.com.br> schreef in bericht Nah, its just a single a randomic name for the webcontrol (WebUserControl). I just added it to project via "Add New Item" menu and choosing WebUserControl from pallete.
:P
 
Got it!!

Need to load from LoadControl() method:

Dim o As Object = Me.LoadControl("mywebcontrol.ascx")
o.Visible = True
Panel1.Controls.Add(o)

[]s
Cesar




Cesar,

If I than understand you well, than you can not do this. It is already there so it is.

MyWebControl.visible = true

Cor
"Cesar Ronchese" <info||carsoftnet.com.br> schreef in bericht Nah, its just a single a randomic name for the webcontrol (WebUserControl). I just added it to project via "Add New Item" menu and choosing WebUserControl from pallete.
:P
 
Back
Top