Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 19, 2008 07:12 AM by niranjana
Jul 05, 2008 08:50 AM|LINK
I am using vb.net.
In my application am using one usercontrol.
i want to call a function from parent after clicking one button in user control
how can i achieve this?
Jul 05, 2008 09:49 AM|LINK
U can call the function using following way.
In Aspx page (ClassName:
Public Function CallFromChildControl()
In Ascx page
However, I will not recommend u to call such method. Rather u should create One Class and Shared function. Afterthen, u can call this function from both ascx page and aspx page.
I hope im clear enough.
Jul 05, 2008 10:11 AM|LINK
This is not working with my application
there if i use my parent class name it is showing error
Jul 05, 2008 10:20 AM|LINK
R u calling parent page function from UserControl's Button Click event? If yes then this should work.
If still ur getting error then plz post ur code.
Jul 05, 2008 07:26 PM|LINK
i will explaing my problem in detail.
I am using asp.net/vb.net.
In my appln. i have one aspx page and 2 user controls.like..below
MainForm --> Parent usercontrol --> child usercontrol
i want to call a method from of Parent usercontrol from my child usercontorl.
Here is my sample code for both parent and child user control
public sub getValues()
some code here
private sub attach()
End Sub -> UCChild is my child user control
public sub read()
private sub attach()
//Here some code
//After this i want to call getValues() from my parent child control
how it possible ?
Jul 06, 2008 05:00 AM|LINK
I understood ur problem. U want to call the method of Child UserControl from Parent UserControl.
In such case u can use the following code.
In Parent.ascx (ClassName: _ParentControl, ChildControl InstanceName:
In Child.ascx (ClassName: _ChildControl)
I hope this will help u.
Jul 06, 2008 10:38 AM|LINK
thank you for giving me such valuable information.
but here i want to call method of my parent control from my child control. not in reverse.
Jul 07, 2008 03:52 AM|LINK
Oh, anyway then look at the following snippet
In Parent.ascx (ClassName: _ParentControl)
Public Sub Read() ' -- This is the function u want to call
Aug 19, 2008 06:58 AM|LINK
finally i got a method to achieve the same
we can use either of the following methods
1) Using delegates
2) Page.GetType().InvokeMember("checkvalues", Reflection.BindingFlags.InvokeMethod, Nothing, Me.Page, Nothing)
where 'checkvalues' is the parent method .
thanks for all for giving me the information
Aug 19, 2008 07:12 AM|LINK
we can use either of the following to call a method of parent control from user contorl
1) Using delegate
2) Page.GetType().InvokeMember("getValues", Reflection.BindingFlags.InvokeMethod, Nothing, Me.Page, Nothing)
where getValues is the parent method