Create and display a Webcontrol created dinamically

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
 
C

Cor Ligthert [MVP]

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
 
C

Cesar Ronchese

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
 
C

Cor Ligthert [MVP]

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
 
C

Cesar Ronchese

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
 

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

Ask a Question

Top