I add the WebUserControl in runtime, so I can't use MyWebUserControl.MyFunction()
, I have a MasterPage and I tried this:
_MainContentPage = CType(_Page.Form.FindControl("MyContentPlaceHolder"), ContentPlaceHolder)
CType(_MainContentPage.FindControl("MyWebUserControl"), myType)
But _MainContentPage.FindControl("MyWebUserControl")
returns a TableCell.
The way I add the WubUserControl:
tcValue = New TableCell()
tcValue.Controls.Add(_Page.LoadControl("Paht/WebUserControl"))
tcValue.ID = "MyWebUserControl"
Well thats cause _MainContentPage.FindControl("MyWebUserControl")
returns a TableCell
but how to get the Webcontrol and call the Function.
The solution is get the TableCell and then find the control, after that call the function.
_MainContentPage = CType(_Page.Form.FindControl("MyContentPlaceHolder"),ContentPlaceHolder)
MyTableCell = CType(_MainContentPage.FindControl("MyWebUserControl"), TableCell)
MyWebControl = CType(MyTableCell.Controls(0), MyType)
MyWebControl.MyFunction()