Last post Nov 03, 2012 09:35 AM by ramiramilu
Nov 03, 2012 05:50 AM|Kavin Guru|LINK
how to register a user control inside codebehind page and i want to call the function inside the control in codebehind page.
For example: my usercontrol name is "testcontroll.ascx" and its codebehind page is"testcontroll.ascx.cs"
and im having "testfunction()" here. my webform name is "testpage.aspx"
and its codebehind page is"testpage.aspx.cs". now i wnt to register "testcontrol.ascx"
inside "testpage.aspx.cs" and i want to call "testfunction()"
Nov 03, 2012 05:53 AM|anil.india|LINK
Nov 03, 2012 05:56 AM|Kavin Guru|LINK
can i have simple example for that.
Nov 03, 2012 06:10 AM|anil.india|LINK
If you want to access your ascx.cs function in your page's code behind then make that function
Now your function can be directly access from your code behind but you have to refer it. So to do so
MyUserControlClassName myUC = new MyUserControlClassName();
No you can call any function of your user control that has public mode like this
myUC.YourMethod( parameters if any pass them);
int result = myUC.YourMethod( parameters if any pass them);
Nov 03, 2012 06:27 AM|kaushikmaheta|LINK
CustomLabelControl myControl = LoadControl("CustomLabelControl.ascx") as CustomLabelControl;
Nov 03, 2012 06:31 AM|Kavin Guru|LINK
this is to call the function inside the usercontrol in our page. but i want to register and too call the function pls help me for that.
Nov 03, 2012 07:49 AM|sureshkumar.gundala|LINK
use the below code to register your user control
<%@ Register TagPrefix="uc" TagName="TestControll" Src="~/Yourpath/TestControll.ascx" %>
Nov 03, 2012 08:47 AM|Kavin Guru|LINK
I want to register the usercontrol inside codebehind page. how to do that?
Nov 03, 2012 09:35 AM|ramiramilu|LINK
sinply use LoadControl and it will take care of everything...http://forums.asp.net/t/1186225.aspx/1?Add+Web+User+Control+from+Code+Behind+
and then you can call your interested method from Usercontrol...