L
Lloyd Sheen
Ok I have created a small testbed site for testing and I am have a problem
with the terms Usercontrol, Webcontrol, etc.
What I need to do in the long run is have a page using AJAX and having
dynamically loaded controls on the page.
So what I did was first create a page with two buttons. First button will
load a Label control into a placeholder. After execution and clicking the
button the label shows in the page.
Next I create a WebUserControl (now is that a UserControl or a WebControl
????) do the same with the other button. The WebUserControl has just a
Label so it should show the same as the first button behaviour I would
think. But nothing shows in the placeholder.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Session("Type") = "One"
Dim ctl As WebControl
Dim lbl As New Label
lbl.Text="This is label1"
ctl = lbl
ctl.Visible = True
Me.PlaceHolder1.Controls.Clear()
Me.PlaceHolder1.Controls.Add(ctl)
End Sub
Above shows the label no problem
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click
Session("Type") = "Two"
Dim ctl As UserControl
ctl = New WebUserControl2
ctl.Visible = True
Me.PlaceHolder1.Controls.Clear()
Me.PlaceHolder1.Controls.Add(ctl)
End Sub
This code shows nothing on the resulting page.
I need to get this working with AJAX but cannot get a simple WebUserControl
on the page.
Any ideas??
Lloyd Sheen
with the terms Usercontrol, Webcontrol, etc.
What I need to do in the long run is have a page using AJAX and having
dynamically loaded controls on the page.
So what I did was first create a page with two buttons. First button will
load a Label control into a placeholder. After execution and clicking the
button the label shows in the page.
Next I create a WebUserControl (now is that a UserControl or a WebControl
????) do the same with the other button. The WebUserControl has just a
Label so it should show the same as the first button behaviour I would
think. But nothing shows in the placeholder.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Session("Type") = "One"
Dim ctl As WebControl
Dim lbl As New Label
lbl.Text="This is label1"
ctl = lbl
ctl.Visible = True
Me.PlaceHolder1.Controls.Clear()
Me.PlaceHolder1.Controls.Add(ctl)
End Sub
Above shows the label no problem
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click
Session("Type") = "Two"
Dim ctl As UserControl
ctl = New WebUserControl2
ctl.Visible = True
Me.PlaceHolder1.Controls.Clear()
Me.PlaceHolder1.Controls.Add(ctl)
End Sub
This code shows nothing on the resulting page.
I need to get this working with AJAX but cannot get a simple WebUserControl
on the page.
Any ideas??
Lloyd Sheen