How to call ASCX page Function on ASPX page?

hooky

New Member
I add the WebUserControl in runtime, so i can't use \[code\]MyWebUserControl.MyFunction()\[/code\], i have a MasterPage and i tried this one:\[code\]_MainContentPage = CType(_Page.Form.FindControl("MyContentPlaceHolder"), ContentPlaceHolder)CType(_MainContentPage.FindControl("MyWebUserControl"), myType)\[/code\]But \[code\]_MainContentPage.FindControl("MyWebUserControl")\[/code\] returns a TableCell.The way i add the WubUserControl:\[code\]tcValue = http://stackoverflow.com/questions/15840090/New TableCell() tcValue.Controls.Add(_Page.LoadControl("Paht/WebUserControl"))tcValue.ID = "MyWebUserControl"\[/code\]Well thats cause \[code\]_MainContentPage.FindControl("MyWebUserControl")\[/code\] returns a TableCellbut how to get the Webcontrol and call the Fcuntion.SolutionThe solution is get the TableCell and then find the control, after that call the function.\[code\]_MainContentPage = CType(_Page.Form.FindControl("MyContentPlaceHolder"),ContentPlaceHolder)MyTableCell = CType(_MainContentPage.FindControl("MyWebUserControl"), TableCell)MyWebControl = CType(MyTableCell.Controls(0), MyType)MyWebControl.MyFunction()\[/code\]thanks in advance.
 
Back
Top