Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
m_btn.RenderControl(output)
End Sub
Private Sub wcl_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Init
m_btn.Text = "test button"
Me.Controls.Add(m_btn)
End Sub
3. I create a test project called testwcl
4. In the test project I add WebUserControl1
5. I drag the wcl control from the toolbox to the WebUserControl
6. In the Default WebForm of the test project I put a placeholder - ph. And
a button - Button1
Here comes the trick.
If I put the following code
ph.Controls.Add(LoadControl("WebUserControl1.ascx"))
in the event Page_Load of the WebForm and I run the project - it works.
Which is I see the WebUserControl on the WebForm and if I press the button
constructed from the library I receive the event Click in the library.
But if I move the above mentioned piece of code in the event Page_PreRender
or Button1_Click then it does not work. Which is I run the project press the
button constructed from the library and the click event does not occur. WHY?
So actually it appears that it works properly only if I load the control in
the Load event. But I can't do that because I want to add different
webusercontrol at runtime. And in runtime if I have a combobox from which to
select which control to be loaded and do the load on bombo_click the I don't
receive the button_click events in the library!!!
Any suggestions?
thanks,
Simon
"Bisser Milanov" <b...@bm.bm> wrote in message
news:#iRLhUEN...@TK2MSFTNGP12.phx.gbl...